From 9d3f1198b931e2e027f6fb69850fb3b754599aa5 Mon Sep 17 00:00:00 2001 From: atom0s Date: Fri, 31 Jan 2025 19:29:00 +0000 Subject: [PATCH 1/6] Add definitions for MoghouseFlg --- src/map/packets/char_health.cpp | 8 ++++++++ src/map/packets/char_sync.cpp | 8 ++++++++ src/map/packets/party_member_update.cpp | 11 +++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/map/packets/char_health.cpp b/src/map/packets/char_health.cpp index 7bf90a6c3aa..fe3bd82014b 100644 --- a/src/map/packets/char_health.cpp +++ b/src/map/packets/char_health.cpp @@ -28,6 +28,7 @@ #include "monstrosity.h" +// https://github.com/atom0s/XiPackets/tree/main/world/server/0x00DF CCharHealthPacket::CCharHealthPacket(CCharEntity* PChar) { this->setType(0xDF); @@ -44,6 +45,13 @@ CCharHealthPacket::CCharHealthPacket(CCharEntity* PChar) ref(0x16) = PChar->GetHPP(); ref(0x17) = PChar->GetMPP(); + // 0x18: Kind + + if (PChar->isMoghouseOpen()) + { + ref(0x19) = 0x01; // MoghouseFlg + } + if (PChar->m_PMonstrosity != nullptr) { ref(0x1C) = monstrosity::GetPackedMonstrosityName(PChar); diff --git a/src/map/packets/char_sync.cpp b/src/map/packets/char_sync.cpp index db4db991bc1..9e2b7af2438 100644 --- a/src/map/packets/char_sync.cpp +++ b/src/map/packets/char_sync.cpp @@ -26,6 +26,7 @@ #include "entities/charentity.h" #include "status_effect_container.h" +// https://github.com/atom0s/XiPackets/tree/main/world/server/0x0067 CCharSyncPacket::CCharSyncPacket(CCharEntity* PChar) { this->setType(0x67); @@ -56,6 +57,13 @@ CCharSyncPacket::CCharSyncPacket(CCharEntity* PChar) ref(0x18) = PChar->m_FieldChocobo; } + // 0x20: UniqueNoMog? + + if (PChar->isMoghouseOpen()) + { + ref(0x24) = 0x01; // MogHouseFlag + } + ref(0x25) = PChar->jobs.job[PChar->GetMJob()]; // Moghouse menu flags? diff --git a/src/map/packets/party_member_update.cpp b/src/map/packets/party_member_update.cpp index bf711772508..f3e0d7aaa8d 100644 --- a/src/map/packets/party_member_update.cpp +++ b/src/map/packets/party_member_update.cpp @@ -30,6 +30,7 @@ #include "entities/trustentity.h" #include "party.h" +// https://github.com/atom0s/XiPackets/tree/main/world/server/0x00DD CPartyMemberUpdatePacket::CPartyMemberUpdatePacket(CCharEntity* PChar, uint8 MemberNumber, uint16 memberflags, uint16 ZoneID) { this->setType(0xDD); @@ -61,8 +62,14 @@ CPartyMemberUpdatePacket::CPartyMemberUpdatePacket(CCharEntity* PChar, uint8 Mem ref(0x10) = PChar->health.tp; ref(0x18) = PChar->targid; ref(0x1A) = MemberNumber; - ref(0x1D) = PChar->GetHPP(); - ref(0x1E) = PChar->GetMPP(); + + if (PChar->isMoghouseOpen()) + { + ref(0x1B) = 0x01; // MoghouseFlg + } + + ref(0x1D) = PChar->GetHPP(); + ref(0x1E) = PChar->GetMPP(); if (!PChar->isAnon()) { From 971f94784624f25953ec4640698223856bb220f6 Mon Sep 17 00:00:00 2001 From: Zach Toogood Date: Fri, 31 Jan 2025 19:29:11 +0000 Subject: [PATCH 2/6] Start on Open Moghouse --- .../zones/Windurst_Walls/DefaultActions.lua | 1 - .../Windurst_Walls/npcs/Shinchai-Tocchai.lua | 44 +++++++++++++++++++ src/map/entities/baseentity.cpp | 8 +++- src/map/entities/baseentity.h | 8 ++-- src/map/entities/charentity.cpp | 26 +++++++++++ src/map/entities/charentity.h | 6 +++ src/map/packet_system.cpp | 8 ++++ src/map/zone_entities.cpp | 2 +- 8 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 scripts/zones/Windurst_Walls/npcs/Shinchai-Tocchai.lua diff --git a/scripts/zones/Windurst_Walls/DefaultActions.lua b/scripts/zones/Windurst_Walls/DefaultActions.lua index ac0c123d08d..dc0628cd29a 100644 --- a/scripts/zones/Windurst_Walls/DefaultActions.lua +++ b/scripts/zones/Windurst_Walls/DefaultActions.lua @@ -49,7 +49,6 @@ return { ['Purere'] = { event = 311 }, ['Quentin'] = { event = 334 }, ['Shantotto'] = { event = 164 }, - ['Shinchai-Tocchai'] = { event = 505 }, ['Six_of_Diamonds'] = { event = 265 }, ['Suhie-Kaihie'] = { event = 291 }, ['Takoda'] = { event = 332 }, diff --git a/scripts/zones/Windurst_Walls/npcs/Shinchai-Tocchai.lua b/scripts/zones/Windurst_Walls/npcs/Shinchai-Tocchai.lua new file mode 100644 index 00000000000..7e54d69463f --- /dev/null +++ b/scripts/zones/Windurst_Walls/npcs/Shinchai-Tocchai.lua @@ -0,0 +1,44 @@ +----------------------------------- +-- Area: Windurst Walls +-- NPC: Shinchai-Tocchai +-- !pos -220.551 0.999 -116.916 239 +----------------------------------- +---@type TNpcEntity +local entity = {} + +entity.onTrigger = function(player, npc) + print("Triggered: ", player, npc) + + -- Caps: 505, 0, 3, 1, 300, 2600, 1543, 1411472642, 128 + player:startEvent(505, player:getNation()) -- , 3, 1, 300, 2600, 1543, 1411472642, 128) +end + +entity.onEventUpdate = function(player, csid, option) + print("Update: CSID:", csid, "Option:", option) +end + +entity.onEventFinish = function(player, csid, option) + print("Finish: CSID:", csid, "Option:", option) + + if player:getPartySize() < 2 then + return + end + + if option < 1 or option > 6 or option > player:getPartySize() then + return + end + + local party = player:getParty() + table.sort(party, function(a, b) + return a:getID() < b:getID() + end) + + local visitTarget = party[option] + if visitTarget == nil then + return + end + + player:gotoPlayer(visitTarget:getName()) +end + +return entity diff --git a/src/map/entities/baseentity.cpp b/src/map/entities/baseentity.cpp index 8d33caea102..bee4b67a1f7 100644 --- a/src/map/entities/baseentity.cpp +++ b/src/map/entities/baseentity.cpp @@ -215,9 +215,13 @@ void CBaseEntity::ResetLocalVars() m_localVars.clear(); } -uint32 CBaseEntity::GetLocalVar(const std::string& var) +uint32 CBaseEntity::GetLocalVar(const std::string& var) const { - return m_localVars[var]; + if (const auto it = m_localVars.find(var); it != m_localVars.end()) + { + return it->second; + } + return 0; } std::map& CBaseEntity::GetLocalVars() diff --git a/src/map/entities/baseentity.h b/src/map/entities/baseentity.h index b594545f700..ccd878a90a7 100644 --- a/src/map/entities/baseentity.h +++ b/src/map/entities/baseentity.h @@ -288,10 +288,10 @@ class CBaseEntity CBaseEntity* GetEntity(uint16 targid, uint8 filter = -1) const; void SendZoneUpdate(); - void ResetLocalVars(); - uint32 GetLocalVar(const std::string& var); - void SetLocalVar(const std::string& var, uint32 val); - auto GetLocalVars() -> std::map&; + void ResetLocalVars(); + auto GetLocalVar(const std::string& var) const -> uint32; + void SetLocalVar(const std::string& var, uint32 val); + auto GetLocalVars() -> std::map&; // pre-tick update virtual void Tick(time_point) = 0; diff --git a/src/map/entities/charentity.cpp b/src/map/entities/charentity.cpp index 65de906dbf1..7d20f9ea892 100644 --- a/src/map/entities/charentity.cpp +++ b/src/map/entities/charentity.cpp @@ -766,6 +766,32 @@ CItemContainer* CCharEntity::getStorage(uint8 LocationID) return nullptr; } +bool CCharEntity::isInMoghouse() const +{ + return m_moghouseID > 0; +} + +bool CCharEntity::isInOwnMoghouse() const +{ + return isInMoghouse() && m_moghouseID == id; +} + +bool CCharEntity::isInOthersMoghouse() const +{ + return isInMoghouse() && m_moghouseID != id; +} + +bool CCharEntity::isMoghouseOpen() const +{ + return this->GetLocalVar("MoghouseOpen") == 1; +} + +void CCharEntity::setMoghouseOpen(bool open) +{ + this->SetLocalVar("MoghouseOpen", open ? 1 : 0); + ReloadPartyInc(); +} + int8 CCharEntity::getShieldSize() { CItemEquipment* PItem = getEquip(SLOT_SUB); diff --git a/src/map/entities/charentity.h b/src/map/entities/charentity.h index 60f65652f01..9887503ee1d 100644 --- a/src/map/entities/charentity.h +++ b/src/map/entities/charentity.h @@ -539,6 +539,12 @@ class CCharEntity : public CBattleEntity uint32 m_moghouseID; uint16 m_moghancementID; + bool isInMoghouse() const; + bool isInOwnMoghouse() const; + bool isInOthersMoghouse() const; + bool isMoghouseOpen() const; + void setMoghouseOpen(bool open); + CharHistory_t m_charHistory; int8 getShieldSize(); diff --git a/src/map/packet_system.cpp b/src/map/packet_system.cpp index a8a138b0edf..1c9edd559a2 100644 --- a/src/map/packet_system.cpp +++ b/src/map/packet_system.cpp @@ -5129,10 +5129,18 @@ void SmallPacket0x0CB(map_session_data_t* const PSession, CCharEntity* const PCh // NOTE: If you zone or move floors while in the MH and you have someone visiting, they will be booted. // NOTE: When you zone or move floors your "open MH" flag will be reset. + + // TODO: Only allow this to be changed when you're in your own moghouse + + PChar->setMoghouseOpen(true); } else if (operation == 2) { // close mog house + + // TODO: Only allow this to be changed when you're in your own moghouse + + PChar->setMoghouseOpen(false); } else if (operation == 5) { diff --git a/src/map/zone_entities.cpp b/src/map/zone_entities.cpp index 91652a06132..5d7fd32b47c 100644 --- a/src/map/zone_entities.cpp +++ b/src/map/zone_entities.cpp @@ -1172,7 +1172,7 @@ void CZoneEntities::SpawnConditionalNPCs(CCharEntity* PChar) TracyZoneScoped; // Player information - const bool inMogHouse = PChar->m_moghouseID > 0; + const bool inMogHouse = PChar->isInOwnMoghouse(); const bool inMHinHomeNation = inMogHouse && [&]() { switch (zoneutils::GetCurrentRegion(PChar->getZone())) From 4537ce74d233315f85d9139497053096eae3ac45 Mon Sep 17 00:00:00 2001 From: Zach Toogood Date: Sat, 1 Feb 2025 11:26:01 +0000 Subject: [PATCH 3/6] Core: Add CPartyMemberDefinePacket Co-authored-by: atom0s --- .../Windurst_Walls/npcs/Shinchai-Tocchai.lua | 8 -- src/map/packets/CMakeLists.txt | 2 + src/map/packets/party_member_define.cpp | 122 ++++++++++++++++++ src/map/packets/party_member_define.h | 39 ++++++ 4 files changed, 163 insertions(+), 8 deletions(-) create mode 100644 src/map/packets/party_member_define.cpp create mode 100644 src/map/packets/party_member_define.h diff --git a/scripts/zones/Windurst_Walls/npcs/Shinchai-Tocchai.lua b/scripts/zones/Windurst_Walls/npcs/Shinchai-Tocchai.lua index 7e54d69463f..f60ccdfcc1b 100644 --- a/scripts/zones/Windurst_Walls/npcs/Shinchai-Tocchai.lua +++ b/scripts/zones/Windurst_Walls/npcs/Shinchai-Tocchai.lua @@ -7,19 +7,11 @@ local entity = {} entity.onTrigger = function(player, npc) - print("Triggered: ", player, npc) - -- Caps: 505, 0, 3, 1, 300, 2600, 1543, 1411472642, 128 player:startEvent(505, player:getNation()) -- , 3, 1, 300, 2600, 1543, 1411472642, 128) end -entity.onEventUpdate = function(player, csid, option) - print("Update: CSID:", csid, "Option:", option) -end - entity.onEventFinish = function(player, csid, option) - print("Finish: CSID:", csid, "Option:", option) - if player:getPartySize() < 2 then return end diff --git a/src/map/packets/CMakeLists.txt b/src/map/packets/CMakeLists.txt index b79659e1240..7e1fb680160 100644 --- a/src/map/packets/CMakeLists.txt +++ b/src/map/packets/CMakeLists.txt @@ -184,6 +184,8 @@ set(PACKET_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/party_invite.h ${CMAKE_CURRENT_SOURCE_DIR}/party_map.cpp ${CMAKE_CURRENT_SOURCE_DIR}/party_map.h + ${CMAKE_CURRENT_SOURCE_DIR}/party_member_define.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/party_member_define.h ${CMAKE_CURRENT_SOURCE_DIR}/party_member_update.cpp ${CMAKE_CURRENT_SOURCE_DIR}/party_member_update.h ${CMAKE_CURRENT_SOURCE_DIR}/party_search.cpp diff --git a/src/map/packets/party_member_define.cpp b/src/map/packets/party_member_define.cpp new file mode 100644 index 00000000000..dabd17651ff --- /dev/null +++ b/src/map/packets/party_member_define.cpp @@ -0,0 +1,122 @@ +/* +=========================================================================== + + Copyright (c) 2025 LandSandBoat Dev Teams + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see http://www.gnu.org/licenses/ + +=========================================================================== +*/ + +#include "party_member_define.h" + +#include "common/socket.h" + +#include + +#include "alliance.h" +#include "entities/charentity.h" +#include "entities/trustentity.h" +#include "party.h" + +// https://github.com/atom0s/XiPackets/tree/main/world/server/0x00E2 +CPartyMemberDefinePacket::CPartyMemberDefinePacket(CCharEntity* PChar, uint8 MemberNumber, uint16 memberflags, uint16 ZoneID) +{ + this->setType(0xE2); + this->setSize(0x40); + + if (PChar == nullptr) + { + ShowError("CPartyMemberDefinePacket::CPartyMemberDefinePacket() - PChar was null."); + return; + } + + ref(0x04) = PChar->id; + + ref(0x14) = memberflags; + + if (PChar->getZone() != ZoneID) + { + ref(0x20) = PChar->getZone(); + } + else + { + ref(0x08) = PChar->health.hp; + ref(0x0C) = PChar->health.mp; + ref(0x10) = PChar->health.tp; + ref(0x18) = PChar->targid; + ref(0x1A) = MemberNumber; + + if (PChar->isMoghouseOpen()) + { + ref(0x1B) = 0x01; // MoghouseFlg + } + + ref(0x1D) = PChar->GetHPP(); + ref(0x1E) = PChar->GetMPP(); + + if (!PChar->isAnon()) + { + ref(0x22) = PChar->GetMJob(); + ref(0x23) = PChar->GetMLevel(); + ref(0x24) = PChar->GetSJob(); + ref(0x25) = PChar->GetSLevel(); + } + } + + std::memcpy(buffer_.data() + 0x28, PChar->getName().c_str(), PChar->getName().size()); +} + +CPartyMemberDefinePacket::CPartyMemberDefinePacket(CTrustEntity* PTrust, uint8 MemberNumber) +{ + this->setType(0xE2); + this->setSize(0x40); + + if (PTrust == nullptr) + { + ShowError("CPartyMemberDefinePacket::CPartyMemberDefinePacket() - PTrust was null."); + return; + } + + ref(0x04) = PTrust->id; + + ref(0x14) = 0; + ref(0x08) = PTrust->health.hp; + ref(0x0C) = PTrust->health.mp; + ref(0x10) = PTrust->health.tp; + ref(0x18) = PTrust->targid; + ref(0x1A) = MemberNumber; + ref(0x1D) = PTrust->GetHPP(); + ref(0x1E) = PTrust->GetMPP(); + + ref(0x22) = PTrust->GetMJob(); + ref(0x23) = PTrust->GetMLevel(); + ref(0x24) = PTrust->GetSJob(); + ref(0x25) = PTrust->GetSLevel(); + + std::memcpy(buffer_.data() + 0x28, PTrust->packetName.c_str(), PTrust->packetName.size()); +} + +CPartyMemberDefinePacket::CPartyMemberDefinePacket(uint32 id, const std::string& name, uint16 memberFlags, uint8 MemberNumber, uint16 ZoneID) +{ + this->setType(0xE2); + this->setSize(0x40); + + ref(0x04) = id; + + ref(0x14) = memberFlags; + ref(0x20) = ZoneID; + + std::memcpy(buffer_.data() + 0x28, name.c_str(), name.size()); +} diff --git a/src/map/packets/party_member_define.h b/src/map/packets/party_member_define.h new file mode 100644 index 00000000000..6ca01f010d8 --- /dev/null +++ b/src/map/packets/party_member_define.h @@ -0,0 +1,39 @@ +/* +=========================================================================== + + Copyright (c) 2025 LandSandBoat Dev Teams + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see http://www.gnu.org/licenses/ + +=========================================================================== +*/ + +#pragma once + +#include "common/cbasetypes.h" + +#include "basic.h" + +class CCharEntity; +class CTrustEntity; +class CAlliance; + +// https://github.com/atom0s/XiPackets/tree/main/world/server/0x00E2 +class CPartyMemberDefinePacket : public CBasicPacket +{ +public: + CPartyMemberDefinePacket(CCharEntity* PChar, uint8 MemberNumber, uint16 memberflags, uint16 zoneid); + CPartyMemberDefinePacket(CTrustEntity* PTrust, uint8 MemberNumber); + CPartyMemberDefinePacket(uint32 id, const std::string& name, uint16 memberFlags, uint8 MemberNumber, uint16 ZoneID); +}; From 89de7027b7c1cfd38a98785782cde2a2e0cb136f Mon Sep 17 00:00:00 2001 From: Zach Toogood Date: Sat, 1 Feb 2025 13:00:44 +0000 Subject: [PATCH 4/6] Add NPCs for Open Moghouse --- scripts/globals/moghouse.lua | 26 +++++++++++++++++++ .../Aht_Urhgan_Whitegate/DefaultActions.lua | 1 - .../Aht_Urhgan_Whitegate/npcs/Zhamwaa.lua | 17 ++++++++++++ scripts/zones/Al_Zahbi/DefaultActions.lua | 1 - scripts/zones/Al_Zahbi/npcs/Krujaal.lua | 17 ++++++++++++ .../zones/Bastok_Markets/DefaultActions.lua | 2 -- scripts/zones/Bastok_Markets/npcs/Hildith.lua | 17 ++++++++++++ scripts/zones/Bastok_Markets/npcs/Loulia.lua | 17 ++++++++++++ scripts/zones/Bastok_Mines/DefaultActions.lua | 1 - scripts/zones/Bastok_Mines/npcs/Leonie.lua | 17 ++++++++++++ .../zones/Northern_San_dOria/npcs/Pulloie.lua | 18 +++++++++---- scripts/zones/Port_Bastok/DefaultActions.lua | 1 - scripts/zones/Port_Bastok/npcs/Wurteh.lua | 18 +++++++++++++ .../zones/Port_San_dOria/DefaultActions.lua | 1 - .../zones/Port_San_dOria/npcs/Phersula.lua | 17 ++++++++++++ .../zones/Port_Windurst/DefaultActions.lua | 1 - scripts/zones/Port_Windurst/npcs/Boronene.lua | 17 ++++++++++++ .../Southern_San_dOria/DefaultActions.lua | 1 - .../zones/Southern_San_dOria/npcs/Fulchia.lua | 18 +++++++++++++ .../Windurst_Walls/npcs/Shinchai-Tocchai.lua | 22 ++-------------- .../zones/Windurst_Waters/npcs/Machitata.lua | 6 +++-- .../zones/Windurst_Woods/DefaultActions.lua | 1 - .../Windurst_Woods/npcs/Abby_Jalunshi.lua | 17 ++++++++++++ 23 files changed, 217 insertions(+), 37 deletions(-) create mode 100644 scripts/zones/Aht_Urhgan_Whitegate/npcs/Zhamwaa.lua create mode 100644 scripts/zones/Al_Zahbi/npcs/Krujaal.lua create mode 100644 scripts/zones/Bastok_Markets/npcs/Hildith.lua create mode 100644 scripts/zones/Bastok_Markets/npcs/Loulia.lua create mode 100644 scripts/zones/Bastok_Mines/npcs/Leonie.lua create mode 100644 scripts/zones/Port_Bastok/npcs/Wurteh.lua create mode 100644 scripts/zones/Port_San_dOria/npcs/Phersula.lua create mode 100644 scripts/zones/Port_Windurst/npcs/Boronene.lua create mode 100644 scripts/zones/Southern_San_dOria/npcs/Fulchia.lua create mode 100644 scripts/zones/Windurst_Woods/npcs/Abby_Jalunshi.lua diff --git a/scripts/globals/moghouse.lua b/scripts/globals/moghouse.lua index d621eec6b9b..677bd65c3bb 100644 --- a/scripts/globals/moghouse.lua +++ b/scripts/globals/moghouse.lua @@ -168,6 +168,32 @@ xi.moghouse.trySetMusic = function(player) end end +xi.moghouse.visitationNPCOnTrigger = function(player, npc, csid, ahtUrhganArg) + player:startEvent(csid, player:getNation(), ahtUrhganArg) +end + +xi.moghouse.visitationNPCOnEventFinish = function(player, csid, option, visitationCSID) + if csid ~= visitationCSID then + return + end + + if player:getPartySize() < 2 then + return + end + + -- TODO: Does this support alliance? + if option < 1 or option > 6 then + return + end + + for _, member in ipairs(player:getParty()) do + if member:getID() == option then + player:gotoPlayer(member:getName()) + return + end + end +end + xi.moghouse.onMoghouseZoneIn = function(player, prevZone) local cs = -1 diff --git a/scripts/zones/Aht_Urhgan_Whitegate/DefaultActions.lua b/scripts/zones/Aht_Urhgan_Whitegate/DefaultActions.lua index 95709eb535d..01b994a95ae 100644 --- a/scripts/zones/Aht_Urhgan_Whitegate/DefaultActions.lua +++ b/scripts/zones/Aht_Urhgan_Whitegate/DefaultActions.lua @@ -71,7 +71,6 @@ return { ['Wazyih'] = { event = 699 }, ['Zaranf'] = { event = 668 }, ['Zarfhid'] = { event = 220 }, - ['Zhamwaa'] = { event = 500 }, ['Zubyahn'] = { event = 674 }, ['Zwinam'] = { event = 682 }, ['Zyfhil'] = { event = 653 }, diff --git a/scripts/zones/Aht_Urhgan_Whitegate/npcs/Zhamwaa.lua b/scripts/zones/Aht_Urhgan_Whitegate/npcs/Zhamwaa.lua new file mode 100644 index 00000000000..b85d9bdf895 --- /dev/null +++ b/scripts/zones/Aht_Urhgan_Whitegate/npcs/Zhamwaa.lua @@ -0,0 +1,17 @@ +----------------------------------- +-- Area: Aht Urhgan Whitegate +-- NPC: Zhamwaa +-- !pos -103.323 0.001 -76.504 50 +----------------------------------- +---@type TNpcEntity +local entity = {} + +entity.onTrigger = function(player, npc) + xi.moghouse.visitationNPCOnTrigger(player, npc, 500, 7) +end + +entity.onEventFinish = function(player, csid, option) + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 500) +end + +return entity diff --git a/scripts/zones/Al_Zahbi/DefaultActions.lua b/scripts/zones/Al_Zahbi/DefaultActions.lua index 5110301d718..f9d5614a268 100644 --- a/scripts/zones/Al_Zahbi/DefaultActions.lua +++ b/scripts/zones/Al_Zahbi/DefaultActions.lua @@ -18,7 +18,6 @@ return { ['Gaweesh'] = { event = 258 }, ['Hadibal'] = { event = 245 }, ['Iphaaf'] = { event = 254 }, - ['Krujaal'] = { event = 0 }, ['Mihli_Aliapoh'] = { event = 267 }, ['Najaaj'] = { event = 241 }, ['Najelith'] = { event = 269 }, diff --git a/scripts/zones/Al_Zahbi/npcs/Krujaal.lua b/scripts/zones/Al_Zahbi/npcs/Krujaal.lua new file mode 100644 index 00000000000..0eeb3f98fdb --- /dev/null +++ b/scripts/zones/Al_Zahbi/npcs/Krujaal.lua @@ -0,0 +1,17 @@ +----------------------------------- +-- Area: Al Zahbi +-- NPC: Krujaal +-- !pos 36.522 0.000 -63.198 48 +----------------------------------- +---@type TNpcEntity +local entity = {} + +entity.onTrigger = function(player, npc) + xi.moghouse.visitationNPCOnTrigger(player, npc, 0, 7) +end + +entity.onEventFinish = function(player, csid, option) + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 0) +end + +return entity diff --git a/scripts/zones/Bastok_Markets/DefaultActions.lua b/scripts/zones/Bastok_Markets/DefaultActions.lua index 59c670bd8b0..53ba8a06472 100644 --- a/scripts/zones/Bastok_Markets/DefaultActions.lua +++ b/scripts/zones/Bastok_Markets/DefaultActions.lua @@ -17,13 +17,11 @@ return { ['Epione'] = { event = 130 }, ['Foss'] = { event = 270 }, ['Gwill'] = { event = 113 }, - ['Hildith'] = { event = 488 }, ['Horatius'] = { event = 110 }, ['Julio'] = { event = 275 }, ['Ken'] = { event = 361 }, ['Lame_Deer'] = { event = 129 }, ['Lavinia'] = { event = 123 }, - ['Loulia'] = { event = 487 }, ['Marin'] = { event = 361 }, ['Matthias'] = { event = 499 }, ['Michea'] = { event = 125 }, diff --git a/scripts/zones/Bastok_Markets/npcs/Hildith.lua b/scripts/zones/Bastok_Markets/npcs/Hildith.lua new file mode 100644 index 00000000000..28f3c166027 --- /dev/null +++ b/scripts/zones/Bastok_Markets/npcs/Hildith.lua @@ -0,0 +1,17 @@ +----------------------------------- +-- Area: Bastok Markets +-- NPC: Hildith +-- !pos -176.664 -8.000 25.158 235 +----------------------------------- +---@type TNpcEntity +local entity = {} + +entity.onTrigger = function(player, npc) + xi.moghouse.visitationNPCOnTrigger(player, npc, 488) +end + +entity.onEventFinish = function(player, csid, option) + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 488) +end + +return entity diff --git a/scripts/zones/Bastok_Markets/npcs/Loulia.lua b/scripts/zones/Bastok_Markets/npcs/Loulia.lua new file mode 100644 index 00000000000..98ceea0944a --- /dev/null +++ b/scripts/zones/Bastok_Markets/npcs/Loulia.lua @@ -0,0 +1,17 @@ +----------------------------------- +-- Area: Bastok Markets +-- NPC: Loulia +-- !pos -176.212 -8.000 -25.049 235 +----------------------------------- +---@type TNpcEntity +local entity = {} + +entity.onTrigger = function(player, npc) + xi.moghouse.visitationNPCOnTrigger(player, npc, 487) +end + +entity.onEventFinish = function(player, csid, option) + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 487) +end + +return entity diff --git a/scripts/zones/Bastok_Mines/DefaultActions.lua b/scripts/zones/Bastok_Mines/DefaultActions.lua index 30cb7affa4c..cae9e7f9e1e 100644 --- a/scripts/zones/Bastok_Mines/DefaultActions.lua +++ b/scripts/zones/Bastok_Mines/DefaultActions.lua @@ -21,7 +21,6 @@ return { ['Gregory'] = { event = 256 }, ['Gumbah'] = { event = 52 }, ['Hound_Nose'] = { event = 132 }, - ['Leonie'] = { event = 568 }, ['Medicine_Eagle'] = { event = 25 }, ['Mydon'] = { event = 20 }, ['Nangst'] = { event = 24 }, diff --git a/scripts/zones/Bastok_Mines/npcs/Leonie.lua b/scripts/zones/Bastok_Mines/npcs/Leonie.lua new file mode 100644 index 00000000000..6d2c3284d8e --- /dev/null +++ b/scripts/zones/Bastok_Mines/npcs/Leonie.lua @@ -0,0 +1,17 @@ +----------------------------------- +-- Area: Bastok Mines +-- NPC: Leonie +-- !pos 118.871 0.996 -83.916 234 +----------------------------------- +---@type TNpcEntity +local entity = {} + +entity.onTrigger = function(player, npc) + xi.moghouse.visitationNPCOnTrigger(player, npc, 568) +end + +entity.onEventFinish = function(player, csid, option) + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 568) +end + +return entity diff --git a/scripts/zones/Northern_San_dOria/npcs/Pulloie.lua b/scripts/zones/Northern_San_dOria/npcs/Pulloie.lua index 64b019b27b3..ba21dfd9585 100644 --- a/scripts/zones/Northern_San_dOria/npcs/Pulloie.lua +++ b/scripts/zones/Northern_San_dOria/npcs/Pulloie.lua @@ -1,16 +1,24 @@ ----------------------------------- -- Area: Northern San d'Oria -- NPC: Pulloie +-- !pos 132.847 -0.199 -2.627 231 ----------------------------------- ---@type TNpcEntity local entity = {} entity.onTrigger = function(player, npc) - if player:getNation() == 0 then - player:startEvent(595) - else - player:startEvent(598) - end + -- TODO: + -- if player:getNation() == 0 then + -- player:startEvent(595) + -- else + -- player:startEvent(598) + -- end + + xi.moghouse.visitationNPCOnTrigger(player, npc, 838) +end + +entity.onEventFinish = function(player, csid, option) + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 838) end return entity diff --git a/scripts/zones/Port_Bastok/DefaultActions.lua b/scripts/zones/Port_Bastok/DefaultActions.lua index dcf6ad03ac9..7084aff79cf 100644 --- a/scripts/zones/Port_Bastok/DefaultActions.lua +++ b/scripts/zones/Port_Bastok/DefaultActions.lua @@ -60,7 +60,6 @@ return { ['Tilian'] = { event = 100 }, ['Trilok'] = { event = 44 }, ['Varden'] = { event = 141 }, - ['Wurteh'] = { event = 95 }, ['Yazan'] = { event = 190 }, ['Zeldaff'] = { event = 30 }, } diff --git a/scripts/zones/Port_Bastok/npcs/Wurteh.lua b/scripts/zones/Port_Bastok/npcs/Wurteh.lua new file mode 100644 index 00000000000..c1bd77f3f7d --- /dev/null +++ b/scripts/zones/Port_Bastok/npcs/Wurteh.lua @@ -0,0 +1,18 @@ +----------------------------------- +-- Area: Port Bastok +-- NPC: Wurteh +-- !pos 72.782 8.499 -242.102 236 +----------------------------------- +---@type TNpcEntity +local entity = {} + +entity.onTrigger = function(player, npc) + -- TODO: What is csid 95? + xi.moghouse.visitationNPCOnTrigger(player, npc, 382) +end + +entity.onEventFinish = function(player, csid, option) + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 382) +end + +return entity diff --git a/scripts/zones/Port_San_dOria/DefaultActions.lua b/scripts/zones/Port_San_dOria/DefaultActions.lua index bfcd6e73454..a49331f3944 100644 --- a/scripts/zones/Port_San_dOria/DefaultActions.lua +++ b/scripts/zones/Port_San_dOria/DefaultActions.lua @@ -34,7 +34,6 @@ return { ['Miene'] = { event = 553 }, ['Noquerelle'] = { event = 583 }, ['Parcarin'] = { event = 566 }, - ['Phersula'] = { event = 775 }, ['Portaure'] = { event = 651 }, ['Prietta'] = { event = 596 }, ['Rielle'] = { event = 564 }, diff --git a/scripts/zones/Port_San_dOria/npcs/Phersula.lua b/scripts/zones/Port_San_dOria/npcs/Phersula.lua new file mode 100644 index 00000000000..79cacc59ade --- /dev/null +++ b/scripts/zones/Port_San_dOria/npcs/Phersula.lua @@ -0,0 +1,17 @@ +----------------------------------- +-- Area: Port San d'Oria +-- NPC: Phersula +-- !pos 80.316 -15.999 -134.112 232 +----------------------------------- +---@type TNpcEntity +local entity = {} + +entity.onTrigger = function(player, npc) + xi.moghouse.visitationNPCOnTrigger(player, npc, 775) +end + +entity.onEventFinish = function(player, csid, option) + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 775) +end + +return entity diff --git a/scripts/zones/Port_Windurst/DefaultActions.lua b/scripts/zones/Port_Windurst/DefaultActions.lua index 2505a7e0494..644607a098b 100644 --- a/scripts/zones/Port_Windurst/DefaultActions.lua +++ b/scripts/zones/Port_Windurst/DefaultActions.lua @@ -5,7 +5,6 @@ return { ['Ada'] = { event = 44 }, ['Aigneis'] = { event = 192 }, ['Baladanzo'] = { event = 354 }, - ['Boronene'] = { event = 638 }, ['Breanainn'] = { event = 182 }, ['Calixte'] = { event = 46 }, ['Chakwaina'] = { event = 350 }, diff --git a/scripts/zones/Port_Windurst/npcs/Boronene.lua b/scripts/zones/Port_Windurst/npcs/Boronene.lua new file mode 100644 index 00000000000..dbc5965b228 --- /dev/null +++ b/scripts/zones/Port_Windurst/npcs/Boronene.lua @@ -0,0 +1,17 @@ +----------------------------------- +-- Area: Port Windurst +-- NPC: Boronene +-- !pos 201.651 -12.000 229.584 240 +----------------------------------- +---@type TNpcEntity +local entity = {} + +entity.onTrigger = function(player, npc) + xi.moghouse.visitationNPCOnTrigger(player, npc, 638) +end + +entity.onEventFinish = function(player, csid, option) + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 638) +end + +return entity diff --git a/scripts/zones/Southern_San_dOria/DefaultActions.lua b/scripts/zones/Southern_San_dOria/DefaultActions.lua index 622fbe96113..7bf2f02c9ad 100644 --- a/scripts/zones/Southern_San_dOria/DefaultActions.lua +++ b/scripts/zones/Southern_San_dOria/DefaultActions.lua @@ -24,7 +24,6 @@ return { ['Estiliphire'] = { event = 897 }, ['Femitte'] = { event = 661 }, ['Foletta'] = { event = 666 }, - ['Fulchia'] = { event = 587 }, ['Gizel'] = { event = 676 }, ['Guilboire'] = { event = 657 }, ['Hae_Jakhya'] = { event = 610 }, diff --git a/scripts/zones/Southern_San_dOria/npcs/Fulchia.lua b/scripts/zones/Southern_San_dOria/npcs/Fulchia.lua new file mode 100644 index 00000000000..7ca5c7da915 --- /dev/null +++ b/scripts/zones/Southern_San_dOria/npcs/Fulchia.lua @@ -0,0 +1,18 @@ +----------------------------------- +-- Area: Northern San d'Oria +-- NPC: Fulchia +-- !pos 158.522 -1.999 164.928 230 +----------------------------------- +---@type TNpcEntity +local entity = {} + +entity.onTrigger = function(player, npc) + -- TODO: 585, 587? + xi.moghouse.visitationNPCOnTrigger(player, npc, 893) +end + +entity.onEventFinish = function(player, csid, option) + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 893) +end + +return entity diff --git a/scripts/zones/Windurst_Walls/npcs/Shinchai-Tocchai.lua b/scripts/zones/Windurst_Walls/npcs/Shinchai-Tocchai.lua index f60ccdfcc1b..8f2b0767990 100644 --- a/scripts/zones/Windurst_Walls/npcs/Shinchai-Tocchai.lua +++ b/scripts/zones/Windurst_Walls/npcs/Shinchai-Tocchai.lua @@ -8,29 +8,11 @@ local entity = {} entity.onTrigger = function(player, npc) -- Caps: 505, 0, 3, 1, 300, 2600, 1543, 1411472642, 128 - player:startEvent(505, player:getNation()) -- , 3, 1, 300, 2600, 1543, 1411472642, 128) + xi.moghouse.visitationNPCOnTrigger(player, npc, 505) end entity.onEventFinish = function(player, csid, option) - if player:getPartySize() < 2 then - return - end - - if option < 1 or option > 6 or option > player:getPartySize() then - return - end - - local party = player:getParty() - table.sort(party, function(a, b) - return a:getID() < b:getID() - end) - - local visitTarget = party[option] - if visitTarget == nil then - return - end - - player:gotoPlayer(visitTarget:getName()) + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 505) end return entity diff --git a/scripts/zones/Windurst_Waters/npcs/Machitata.lua b/scripts/zones/Windurst_Waters/npcs/Machitata.lua index 109515539d7..449c2be8b88 100644 --- a/scripts/zones/Windurst_Waters/npcs/Machitata.lua +++ b/scripts/zones/Windurst_Waters/npcs/Machitata.lua @@ -2,7 +2,7 @@ -- Area: Windurst Waters -- NPC: Machitata -- Involved in Quest: Hat in Hand --- !pos 163 0 -22 238 +-- !pos 164.230 0.999 -25.400 238 ----------------------------------- local ID = zones[xi.zone.WINDURST_WATERS] ----------------------------------- @@ -17,7 +17,7 @@ entity.onTrigger = function(player, npc) player:messageSpecial(ID.text.YOU_SHOW_OFF_THE, 0, xi.ki.NEW_MODEL_HAT) player:startEvent(58) else - player:startEvent(526) + xi.moghouse.visitationNPCOnTrigger(player, npc, 984) end end @@ -25,6 +25,8 @@ entity.onEventFinish = function(player, csid, option, npc) if csid == 58 then player:setCharVar('QuestHatInHand_var', utils.mask.setBit(player:getCharVar('QuestHatInHand_var'), 0, true)) player:incrementCharVar('QuestHatInHand_count', 1) + else + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 984) end end diff --git a/scripts/zones/Windurst_Woods/DefaultActions.lua b/scripts/zones/Windurst_Woods/DefaultActions.lua index c6ebdaa8966..c1a6a0b255b 100644 --- a/scripts/zones/Windurst_Woods/DefaultActions.lua +++ b/scripts/zones/Windurst_Woods/DefaultActions.lua @@ -1,7 +1,6 @@ -- local ID = zones[xi.zone.WINDURST_WOODS] return { - ['Abby_Jalunshi'] = { event = 798 }, ['Aja-Panja'] = { event = 247 }, ['An_Polaali'] = { event = 44 }, ['An_Shanaa'] = { event = 45 }, diff --git a/scripts/zones/Windurst_Woods/npcs/Abby_Jalunshi.lua b/scripts/zones/Windurst_Woods/npcs/Abby_Jalunshi.lua new file mode 100644 index 00000000000..9e5e513ffbe --- /dev/null +++ b/scripts/zones/Windurst_Woods/npcs/Abby_Jalunshi.lua @@ -0,0 +1,17 @@ +----------------------------------- +-- Area: Windurst Woods +-- NPC: Abby Jalunshi +-- !pos -101.895 -4.000 36.172 241 +----------------------------------- +---@type TNpcEntity +local entity = {} + +entity.onTrigger = function(player, npc) + xi.moghouse.visitationNPCOnTrigger(player, npc, 798) +end + +entity.onEventFinish = function(player, csid, option) + xi.moghouse.visitationNPCOnEventFinish(player, csid, option, 798) +end + +return entity From d2711b217e4a63dad64c0a7d4018a75b815dcb00 Mon Sep 17 00:00:00 2001 From: Zach Toogood Date: Sat, 1 Feb 2025 13:04:28 +0000 Subject: [PATCH 5/6] Lock MH actions inside own MH --- src/map/packet_system.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/map/packet_system.cpp b/src/map/packet_system.cpp index 1c9edd559a2..76eb4f854b5 100644 --- a/src/map/packet_system.cpp +++ b/src/map/packet_system.cpp @@ -5122,27 +5122,29 @@ void SmallPacket0x0CB(map_session_data_t* const PSession, CCharEntity* const PCh { TracyZoneScoped; + if (!PChar->isInOwnMoghouse()) + { + ShowWarningFmt("Player {} ({}) is trying to perform a moghouse action while not in their own moghouse.", PChar->getName(), PChar->id); + return; + } + auto operation = data.ref(0x04); - if (operation == 1) + if (operation == 0x01) { // open mog house // NOTE: If you zone or move floors while in the MH and you have someone visiting, they will be booted. // NOTE: When you zone or move floors your "open MH" flag will be reset. - // TODO: Only allow this to be changed when you're in your own moghouse - PChar->setMoghouseOpen(true); } - else if (operation == 2) + else if (operation == 0x02) { // close mog house - // TODO: Only allow this to be changed when you're in your own moghouse - PChar->setMoghouseOpen(false); } - else if (operation == 5) + else if (operation == 0x05) { // remodel mog house auto type = data.ref(0x06); // Sandy: 103, Bastok: 104, Windy: 105, Patio: 106 From a25a56edf6518b66155e838ababf021672483212 Mon Sep 17 00:00:00 2001 From: Zach Toogood Date: Sat, 1 Feb 2025 14:18:07 +0000 Subject: [PATCH 6/6] Add note about Moghouse visit client limitation --- scripts/globals/moghouse.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/globals/moghouse.lua b/scripts/globals/moghouse.lua index 677bd65c3bb..e844b5ede1d 100644 --- a/scripts/globals/moghouse.lua +++ b/scripts/globals/moghouse.lua @@ -169,20 +169,27 @@ xi.moghouse.trySetMusic = function(player) end xi.moghouse.visitationNPCOnTrigger = function(player, npc, csid, ahtUrhganArg) + if player:getPartySize() > 1 then + for _, member in ipairs(player:getParty()) do + if member:getID() == 1 and member:isInMogHouse() then + player:printToPlayer(string.format('Client limitation: Players with ID 1 (%s) seemingly cannot be visited in their Mog House', member:getName()), xi.msg.channel.SYSTEM_3, '') + end + end + end + player:startEvent(csid, player:getNation(), ahtUrhganArg) end xi.moghouse.visitationNPCOnEventFinish = function(player, csid, option, visitationCSID) - if csid ~= visitationCSID then + if option == 0 or option == utils.EVENT_CANCELLED_OPTION then return end - if player:getPartySize() < 2 then + if csid ~= visitationCSID then return end - -- TODO: Does this support alliance? - if option < 1 or option > 6 then + if player:getPartySize() < 2 then return end