From adc8f96eb521066a2953620d0965a98b94a1cb33 Mon Sep 17 00:00:00 2001 From: Mitachi <70312009+Mitachi2611@users.noreply.github.com> Date: Tue, 23 Jul 2024 09:31:14 +0200 Subject: [PATCH] Patch 0.2 --- Srcs-Server/game/src/char.cpp | 22 +----------- Srcs-Server/game/src/char.h | 2 ++ Srcs-Server/game/src/char_horse.cpp | 42 ++++++++++++++++------ Srcs-Server/game/src/char_item.cpp | 13 +++++-- Srcs-Server/game/src/item_manager.cpp | 51 +++++++++++++++++++++++++++ 5 files changed, 96 insertions(+), 34 deletions(-) create mode 100644 Srcs-Server/game/src/item_manager.cpp diff --git a/Srcs-Server/game/src/char.cpp b/Srcs-Server/game/src/char.cpp index 7a5ea12..cbdddb4 100644 --- a/Srcs-Server/game/src/char.cpp +++ b/Srcs-Server/game/src/char.cpp @@ -39,26 +39,6 @@ // and add under, this: #ifdef ENABLE_MOUNT_LIKE_HORSE - RemoveAffect(AFFECT_MOUNT_BONUS); if (const auto pMountItem = GetWear(WEAR_COSTUME_MOUNT)) - { - for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i) { - if (pMountItem->GetProto()->aApplies[i].bType == APPLY_NONE || vnum == 0) - continue; - AddAffect(AFFECT_MOUNT_BONUS, aApplyInfo[pMountItem->GetProto()->aApplies[i].bType].bPointType, pMountItem->GetProto()->aApplies[i].lValue, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false); - } - } + CalcBonusMount(pMountItem); #endif - -/// 3.) Add at the end of the file: - -#ifdef ENABLE_MOUNT_LIKE_HORSE -void CHARACTER::CheckEnterMount() -{ - if (GetHorse()) // If is already summoned, do nothing - return; - - if (const auto pMountItem = GetWear(WEAR_COSTUME_MOUNT)) - HorseSummon(true, false, pMountItem->GetValue(1)); -} -#endif \ No newline at end of file diff --git a/Srcs-Server/game/src/char.h b/Srcs-Server/game/src/char.h index a194ec9..04b1c0a 100644 --- a/Srcs-Server/game/src/char.h +++ b/Srcs-Server/game/src/char.h @@ -9,6 +9,7 @@ ESex GET_SEX(LPCHARACTER ch); #ifdef ENABLE_MOUNT_LIKE_HORSE public: void CheckEnterMount(); + void CalcMountBonusBySeal(const LPITEM pMountItem); #endif // like: @@ -17,6 +18,7 @@ ESex GET_SEX(LPCHARACTER ch); #ifdef ENABLE_MOUNT_LIKE_HORSE public: void CheckEnterMount(); + void CalcMountBonusBySeal(const LPITEM pMountItem); #endif }; diff --git a/Srcs-Server/game/src/char_horse.cpp b/Srcs-Server/game/src/char_horse.cpp index e8b0661..30e5335 100644 --- a/Srcs-Server/game/src/char_horse.cpp +++ b/Srcs-Server/game/src/char_horse.cpp @@ -25,10 +25,8 @@ if (m_chHorse) { #ifdef ENABLE_MOUNT_LIKE_HORSE - if (GetMountVnum() != dwVnum) { - HorseSummon(false); - HorseSummon(true); - } + if (GetMountVnum() != dwVnum) + m_chHorse->SetPolymorph(dwVnum); #endif return; } @@ -45,11 +43,9 @@ void CHARACTER::HorseSummon(bool bSummon, bool bFromFar, DWORD dwVnum, const cha // NOTE: If you summon and there is already a horse, it will do nothing. if (m_chHorse) { -#ifdef ENABLE_MOUNT_LIKE_HORSE // try fix - if (GetMountVnum() != dwVnum) { - HorseSummon(false); - HorseSummon(true); - } +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (GetMountVnum() != dwVnum) + m_chHorse->SetPolymorph(dwVnum); #endif return; } @@ -120,4 +116,30 @@ void CHARACTER::HorseSummon(bool bSummon, bool bFromFar, DWORD dwVnum, const cha m_chHorse->m_stName += LC_TEXT("´ÔÀÇ ¸»"); #endif } -*/ \ No newline at end of file +*/ + +/// 4.) Add at the end of the file: + +#ifdef ENABLE_MOUNT_LIKE_HORSE +void CHARACTER::CheckEnterMount() +{ + if (GetHorse()) // If is already summoned, do nothing + return; + + if (const auto pMountItem = GetWear(WEAR_COSTUME_MOUNT)) + HorseSummon(true, false, pMountItem->GetValue(1)); +} + +void CHARACTER::CalcMountBonusBySeal(const LPITEM pMountItem) +{ + if (!GetMountVnum() || !pMountItem || !pMountItem->IsMount()) + return; + + RemoveAffect(AFFECT_MOUNT_BONUS); + for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i) { + if (pMountItem->GetProto()->aApplies[i].bType == APPLY_NONE || pMountItem->GetValue(1) == 0) + continue; + AddAffect(AFFECT_MOUNT_BONUS, aApplyInfo[pMountItem->GetProto()->aApplies[i].bType].bPointType, pMountItem->GetProto()->aApplies[i].lValue, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false); + } +} +#endif \ No newline at end of file diff --git a/Srcs-Server/game/src/char_item.cpp b/Srcs-Server/game/src/char_item.cpp index 50e4110..511c302 100644 --- a/Srcs-Server/game/src/char_item.cpp +++ b/Srcs-Server/game/src/char_item.cpp @@ -25,10 +25,8 @@ // and add under, this: #ifdef ENABLE_MOUNT_LIKE_HORSE - if (item1->IsMount() && item2->IsMount() && destCell.IsEquipPosition()) { - HorseSummon(false); + if (item1->IsMount() && item2->IsMount() && destCell.IsEquipPosition()) HorseSummon(true); - } #endif /// 3.) Search in bool CHARACTER::UnequipItem(LPITEM item): @@ -52,4 +50,13 @@ #ifdef ENABLE_MOUNT_LIKE_HORSE if (item->IsMount()) HorseSummon(true); +#endif + +/// 5.) in CHARACTER::SetWear(BYTE bCell, LPITEM item): + +// at the end before the }, add: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (item) + CalcBonusMount(item); #endif \ No newline at end of file diff --git a/Srcs-Server/game/src/item_manager.cpp b/Srcs-Server/game/src/item_manager.cpp new file mode 100644 index 0000000..34eb060 --- /dev/null +++ b/Srcs-Server/game/src/item_manager.cpp @@ -0,0 +1,51 @@ +/// 1.) Search in void ITEM_MANAGER::RemoveItem(LPITEM item, const char * c_pszReason) + + } + // END_OF_SAFEBOX_TIME_LIMIT_ITEM_BUG_FIX + else + { + +// and add under, this: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (o->GetWear(WEAR_COSTUME_MOUNT) && item == o->GetWear(WEAR_COSTUME_MOUNT)) { + o->StopRiding(); + o->HorseSummon(false); + } +#endif + +/*Example: +void ITEM_MANAGER::RemoveItem(LPITEM item, const char * c_pszReason) +{ + LPCHARACTER o; + + if ((o = item->GetOwner())) + { + char szHint[64]{}; + snprintf(szHint, sizeof(szHint), "%s %u ", item->GetName(), item->GetCount()); + LogManager::instance().ItemLog(o, item, c_pszReason ? c_pszReason : "REMOVE", szHint); + + // SAFEBOX_TIME_LIMIT_ITEM_BUG_FIX + if (item->GetWindow() == MALL || item->GetWindow() == SAFEBOX) + { + // If you have a timed item in your store, the server will go down when the time expires. + if (const auto pSafebox = item->GetWindow() == MALL ? o->GetMall() : o->GetSafebox()) + pSafebox->Remove(item->GetCell()); + } + // END_OF_SAFEBOX_TIME_LIMIT_ITEM_BUG_FIX + else + { +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (o->GetWear(WEAR_COSTUME_MOUNT) && item == o->GetWear(WEAR_COSTUME_MOUNT)) { + o->StopRiding(); + o->HorseSummon(false); + } +#endif + o->SyncQuickslot(QUICKSLOT_TYPE_ITEM, item->GetCell(), 255); + item->RemoveFromCharacter(); + } + } + + M2_DESTROY_ITEM(item); +} +*/ \ No newline at end of file