From 1a73ca484cf9bab918cdaf1def2cef18de62d64e Mon Sep 17 00:00:00 2001 From: Mitachi <70312009+Mitachi2611@users.noreply.github.com> Date: Mon, 5 Feb 2024 18:59:21 +0100 Subject: [PATCH] Initial commit --- .gitattributes | 2 + README.txt | 16 ++++ Srcs-Server/#undefined/README.txt | 1 + Srcs-Server/#undefined/VnumHelper.h | 22 ++++++ Srcs-Server/#undefined/item.h | 12 +++ Srcs-Server/#undefined/pvp.cpp | 48 +++++++++++ ...ice.h or CommonDefines.h or macroDefines.h | 3 + Srcs-Server/game/src/char.cpp | 64 +++++++++++++++ Srcs-Server/game/src/char.h | 25 ++++++ Srcs-Server/game/src/char_horse.cpp | 79 +++++++++++++++++++ Srcs-Server/game/src/char_item.cpp | 55 +++++++++++++ Srcs-Server/game/src/input_login.cpp | 10 +++ Srcs-Server/game/src/item.cpp | 27 +++++++ 13 files changed, 364 insertions(+) create mode 100644 .gitattributes create mode 100644 README.txt create mode 100644 Srcs-Server/#undefined/README.txt create mode 100644 Srcs-Server/#undefined/VnumHelper.h create mode 100644 Srcs-Server/#undefined/item.h create mode 100644 Srcs-Server/#undefined/pvp.cpp create mode 100644 Srcs-Server/common/service.h or CommonDefines.h or macroDefines.h create mode 100644 Srcs-Server/game/src/char.cpp create mode 100644 Srcs-Server/game/src/char.h create mode 100644 Srcs-Server/game/src/char_horse.cpp create mode 100644 Srcs-Server/game/src/char_item.cpp create mode 100644 Srcs-Server/game/src/input_login.cpp create mode 100644 Srcs-Server/game/src/item.cpp diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..44662a3 --- /dev/null +++ b/README.txt @@ -0,0 +1,16 @@ +Copr. Mitachi + +Pros: +- Fewer lines of code (50 or so, versus 1200+ in the public system) +- By not using apply_type and value to assign the monster to ride, we will not lose a usable bonus +- Being horse-based, trivially it is code that has been tested for years. +- If you are on the mount and warp, you will still be on the mount at login (being that we use EnterHorse) +- You can take advantage of the horse name system with a few modifications +- You only get mount bonuses if you are riding it and not while it is summoned + +Cons: +- I couldn't find any + +USAGE: + Put the mount vnum in the seal item's value1. + You can remove ride.quest or whatever quest you're using for mounts. \ No newline at end of file diff --git a/Srcs-Server/#undefined/README.txt b/Srcs-Server/#undefined/README.txt new file mode 100644 index 0000000..acea8a7 --- /dev/null +++ b/Srcs-Server/#undefined/README.txt @@ -0,0 +1 @@ +This is a change that required by the system but is not part of it, I just moved code \ No newline at end of file diff --git a/Srcs-Server/#undefined/VnumHelper.h b/Srcs-Server/#undefined/VnumHelper.h new file mode 100644 index 0000000..a0bb5fe --- /dev/null +++ b/Srcs-Server/#undefined/VnumHelper.h @@ -0,0 +1,22 @@ +// Search: + + static bool IsPhoenix(DWORD vnum) { return 34001 == vnum; } + +// add under, this: + + static bool IsMount(DWORD vnum) { + switch (vnum) { + case 20030: case 20110: case 20111: case 20112: case 20113: case 20114: case 20115: + case 20116: case 20117: case 20118: case 20205: case 20206: case 20207: case 20208: + case 20209: case 20210: case 20211: case 20212: case 20119: case 20219: case 20220: + case 20221: case 20222: case 20120: case 20121: case 20122: case 20123: case 20124: + case 20125: case 20214: case 20215: case 20217: case 20218: case 20224: case 20225: + case 20226: case 20227: + return true; + default: + return false; + } + } + +// If you are sick: + static constexpr bool IsMount(const DWORD& vnum) noexcept { \ No newline at end of file diff --git a/Srcs-Server/#undefined/item.h b/Srcs-Server/#undefined/item.h new file mode 100644 index 0000000..0a85704 --- /dev/null +++ b/Srcs-Server/#undefined/item.h @@ -0,0 +1,12 @@ +// Search: + + DWORD GetSIGVnum() const + { + return m_dwSIGVnum; + } + +// add under, this: + +// #ifdef ENABLE_MOUNT_COSTUME + const bool IsMount() { return GetType() == ITEM_COSTUME && GetSubType() == COSTUME_MOUNT; } +// #endif \ No newline at end of file diff --git a/Srcs-Server/#undefined/pvp.cpp b/Srcs-Server/#undefined/pvp.cpp new file mode 100644 index 0000000..ebf3461 --- /dev/null +++ b/Srcs-Server/#undefined/pvp.cpp @@ -0,0 +1,48 @@ +// Search: + +#include "locale_service.h" + +// add under, this: + +#include "../../common/VnumHelper.h" + +// Search: + + if( true == pkChr->IsHorseRiding() ) + { + if( pkChr->GetHorseLevel() > 0 && 1 == pkChr->GetHorseGrade() ) + return false; + } + else + { + + if(!g_bAllMountAttack) + { + switch( pkChr->GetMountVnum() ) + { + case 0: + case 20030: + .... + } + } + } + +// and replace with: + + if (pkChr->IsHorseRiding()) + { + if (pkChr->GetHorseLevel() > 0 && 1 == pkChr->GetHorseGrade()) + return false; + } + else { + const auto mountVnum = pkChr->GetMountVnum(); + if (mountVnum != 0 && !CMobVnumHelper::IsMount(mountVnum)) + return false; + } + +/* +NOTE: Make sure that all the cases you had in the switch, +are present in the new IsMount method added in VnumHelper.h + +Also: g_bAllMountAttack comes from novaline, however if you have mainline replace the if/else statement anyway. +*/ \ No newline at end of file diff --git a/Srcs-Server/common/service.h or CommonDefines.h or macroDefines.h b/Srcs-Server/common/service.h or CommonDefines.h or macroDefines.h new file mode 100644 index 0000000..adfb457 --- /dev/null +++ b/Srcs-Server/common/service.h or CommonDefines.h or macroDefines.h @@ -0,0 +1,3 @@ +// Add + +#define ENABLE_MOUNT_LIKE_HORSE \ No newline at end of file diff --git a/Srcs-Server/game/src/char.cpp b/Srcs-Server/game/src/char.cpp new file mode 100644 index 0000000..4e96b83 --- /dev/null +++ b/Srcs-Server/game/src/char.cpp @@ -0,0 +1,64 @@ +/// 1.) Search in void CHARACTER::SetProto(const CMob * pkMob): + + if (m_bCharType == CHAR_TYPE_HORSE || + GetRaceNum() == 20101 || + GetRaceNum() == 20102 || + GetRaceNum() == 20103 || + GetRaceNum() == 20104 || + GetRaceNum() == 20105 || + GetRaceNum() == 20106 || + GetRaceNum() == 20107 || + GetRaceNum() == 20108 || + GetRaceNum() == 20109 + ) + +// and replace with: + + if (m_bCharType == CHAR_TYPE_HORSE || + GetRaceNum() == 20101 || + GetRaceNum() == 20102 || + GetRaceNum() == 20103 || + GetRaceNum() == 20104 || + GetRaceNum() == 20105 || + GetRaceNum() == 20106 || + GetRaceNum() == 20107 || + GetRaceNum() == 20108 || + GetRaceNum() == 20109 +#ifdef ENABLE_MOUNT_LIKE_HORSE + || CMobVnumHelper::IsMount(GetRaceNum()) +#endif + ) + +/// 2.) Search in void CHARACTER::MountVnum(DWORD vnum): + + } + + SetValidComboInterval(0); + SetComboSequence(0); + +// 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, true); + } + } +#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 new file mode 100644 index 0000000..a194ec9 --- /dev/null +++ b/Srcs-Server/game/src/char.h @@ -0,0 +1,25 @@ +/// 1.) Search: + +}; + +ESex GET_SEX(LPCHARACTER ch); + +// and add before, this: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + public: + void CheckEnterMount(); +#endif + +// like: +/* + +#ifdef ENABLE_MOUNT_LIKE_HORSE + public: + void CheckEnterMount(); +#endif +}; + +ESex GET_SEX(LPCHARACTER ch); +#endif +*/ \ No newline at end of file diff --git a/Srcs-Server/game/src/char_horse.cpp b/Srcs-Server/game/src/char_horse.cpp new file mode 100644 index 0000000..b812a76 --- /dev/null +++ b/Srcs-Server/game/src/char_horse.cpp @@ -0,0 +1,79 @@ +/// 1.) Search in bool CHARACTER::StartRiding(): + + return false; + } + + DWORD dwMountVnum = m_chHorse ? m_chHorse->GetRaceNum() : GetMyHorseVnum(); + +// and add under, this: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (const LPITEM pMountItem = GetWear(WEAR_COSTUME_MOUNT)) + dwMountVnum = pMountItem->GetValue(1); +#endif + +// then search: + + UpdatePacket(); + } + + PointChange(POINT_ST, 0); + PointChange(POINT_DX, 0); + PointChange(POINT_HT, 0); + PointChange(POINT_IQ, 0); + +// and add under, this: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + RemoveAffect(AFFECT_MOUNT_BONUS); +#endif + +/// 2.) Search in LPCHARACTER CHARACTER::GetRider() const: + +void CHARACTER::HorseSummon(bool bSummon, bool bFromFar, DWORD dwVnum, const char* pPetName) +{ + +// and add at the init, this: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (const LPITEM pMountItem = GetWear(WEAR_COSTUME_MOUNT)) + dwVnum = pMountItem->GetValue(1); +#endif + +/*Example: +void CHARACTER::HorseSummon(bool bSummon, bool bFromFar, DWORD dwVnum, const char* pPetName) +{ +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (const LPITEM pMountItem = GetWear(WEAR_COSTUME_MOUNT)) + dwVnum = pMountItem->GetValue(1); +#endif + + if (bSummon) + {... +*/ + +/// 3.) Search in void CHARACTER::HorseSummon(bool bSummon, bool bFromFar, DWORD dwVnum, const char* pPetName): + + m_chHorse->m_stName += LC_TEXT("´ÔÀÇ ¸»"); + +// and replace with: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + m_chHorse->m_stName += LC_TEXT(CMobVnumHelper::IsMount(dwVnum) ? "'s Mount" : "´ÔÀÇ ¸»"); +#else + m_chHorse->m_stName += LC_TEXT("´ÔÀÇ ¸»"); +#endif + +/*Example: + if (pHorseName && strlen(pHorseName) != 0) + m_chHorse->m_stName = pHorseName; + else + { + m_chHorse->m_stName = GetName(); +#ifdef ENABLE_MOUNT_LIKE_HORSE + m_chHorse->m_stName += LC_TEXT(CMobVnumHelper::IsMount(dwVnum) ? "'s Mount" : "´ÔÀÇ ¸»"); +#else + m_chHorse->m_stName += LC_TEXT("´ÔÀÇ ¸»"); +#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 new file mode 100644 index 0000000..d630bad --- /dev/null +++ b/Srcs-Server/game/src/char_item.cpp @@ -0,0 +1,55 @@ +/// 1.) Search in bool CHARACTER::MoveItem(TItemPos Cell, TItemPos DestCell, BYTE count): + + if (!CanHandleItem()) + { + if (NULL != DragonSoul_RefineWindow_GetOpener()) + ChatPacket(CHAT_TYPE_INFO, LC_TEXT("°­È­Ã¢À» ¿¬ »óÅ¿¡¼­´Â ¾ÆÀÌÅÛÀ» ¿Å±æ ¼ö ¾ø½À´Ï´Ù.")); + return false; + } + +// and add under, this: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (item->IsMount() && item->IsEquipped() && DestCell.IsDefaultInventoryPosition()) { + StopRiding(); + HorseSummon(false); + } +#endif + +/// 2.) Search in bool CHARACTER::SwapItem(BYTE bCell, BYTE bDestCell): + + item1->AddToCharacter(this, TItemPos(INVENTORY, bCell2)); + item2->AddToCharacter(this, TItemPos(INVENTORY, bCell1)); + } + +// and add under, this: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (item1->IsMount() && item2->IsMount() && destCell.IsEquipPosition()) { + HorseSummon(false); + HorseSummon(true); + } +#endif + +/// 3.) Search in bool CHARACTER::UnequipItem(LPITEM item): + + if (!CanUnequipNow(item)) + return false; + +// and add before, this: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (item->IsMount()) { + StopRiding(); + HorseSummon(false); + } +#endif + +/// 4.) in bool CHARACTER::UnequipItem(LPITEM item): + +// before the final "return true;", add this: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (item->IsMount()) + HorseSummon(true); +#endif \ No newline at end of file diff --git a/Srcs-Server/game/src/input_login.cpp b/Srcs-Server/game/src/input_login.cpp new file mode 100644 index 0000000..35754f0 --- /dev/null +++ b/Srcs-Server/game/src/input_login.cpp @@ -0,0 +1,10 @@ +/// 1.) Search in void CInputLogin::Entergame(LPDESC d, const char * data): + + if (ch->GetHorseLevel() > 0) + ch->EnterHorse(); + +// and add under, this: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + ch->CheckEnterMount(); +#endif \ No newline at end of file diff --git a/Srcs-Server/game/src/item.cpp b/Srcs-Server/game/src/item.cpp new file mode 100644 index 0000000..09a62ad --- /dev/null +++ b/Srcs-Server/game/src/item.cpp @@ -0,0 +1,27 @@ +/// 1.) Search in void CItem::ModifyPoints(bool bAdd): + + for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i) + { + if (m_pProto->aApplies[i].bType == APPLY_NONE) + continue; + +// and add under, this: + +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (IsMount()) + continue; +#endif + +/*Example: + for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i) + { + if (m_pProto->aApplies[i].bType == APPLY_NONE) + continue; +#ifdef ENABLE_MOUNT_LIKE_HORSE + if (IsMount()) + continue; +#endif + + long value = m_pProto->aApplies[i].lValue; + ... +*/ \ No newline at end of file