From d828f75b3d623bbd375c861d87acfea2c4145a12 Mon Sep 17 00:00:00 2001 From: Luxion <76599640+LuxionUO@users.noreply.github.com> Date: Wed, 23 Aug 2023 21:02:47 +0100 Subject: [PATCH 1/4] Monsters' AI fixed The issue with the Heuristic function in CPathFinder has been fixed. Now, the monsters correctly follow their targets without any problems. They are now able to effectively navigate around obstacles and move in a straight path. Additionally, the problem of zig-zag issue following in the South direction has been addressed. --- Changelog.txt | 3 +++ src/game/CPathFinder.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 437980ef1..91554723b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3303,3 +3303,6 @@ Fixed: Multi type items weren't calling the @Destroy triggers when removed. (Iss 21-08-2023, Rastrero/Drk84 -Fixed-> Removed exception for poison bottles at CClientUSe.cpp so now poison potions are handled as any other potion at CCharuse.cpp Thx Drk84 for the suggestion. I dont understand why there was that exception done. Are we missing something? + +23-08-2023, Luxion +- Fixed: The issue with the Heuristic function in CPathFinder has been fixed. Now, the monsters correctly follow their targets without any problems. They are now able to effectively navigate around obstacles and move in a straight path. Additionally, the problem of zig-zag issue following in the South direction has been addressed. diff --git a/src/game/CPathFinder.cpp b/src/game/CPathFinder.cpp index 4c5bdefd3..89ff8bb2b 100644 --- a/src/game/CPathFinder.cpp +++ b/src/game/CPathFinder.cpp @@ -9,10 +9,10 @@ int CPathFinder::Heuristic(const CPathFinderPoint* Pt1, const CPathFinderPoint* Pt2) noexcept // static { // Hexagonal heuristic (thought for a hexagonal grid, but in our case, by using this, the movements are more natural and the rotation angles more wide) - return 10*(abs(Pt1->m_x - Pt2->m_x) + abs(Pt1->m_y - Pt2->m_y)); + //return 10*(abs(Pt1->m_x - Pt2->m_x) + abs(Pt1->m_y - Pt2->m_y)); // Diagonal heuristic, thought for a square grid which allows movement in 8 directions from a cell (our case) - //return std::max(abs(Pt1->m_x - Pt2->m_x), abs(Pt1->m_y - Pt2->m_y)); + return std::max(abs(Pt1->m_x - Pt2->m_x), abs(Pt1->m_y - Pt2->m_y)); } void CPathFinder::GetAdjacentCells(const CPathFinderPoint* Point, std::deque& AdjacentCellsRefList ) From 77bdac48d30a41e3a13f70cfcebf124889f2af8f Mon Sep 17 00:00:00 2001 From: Luxion <76599640+LuxionUO@users.noreply.github.com> Date: Mon, 28 Aug 2023 20:31:58 +0100 Subject: [PATCH 2/4] INI Setting to switch Heuristic By activating a new flag on sphere.ini will be possible to switch the heuristic function diagonal or hexagonal. --- Changelog.txt | 1 + src/game/CPathFinder.cpp | 9 +++++---- src/game/CServerConfig.h | 1 + src/sphere.ini | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 91554723b..d07097eb5 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3306,3 +3306,4 @@ Fixed: Multi type items weren't calling the @Destroy triggers when removed. (Iss 23-08-2023, Luxion - Fixed: The issue with the Heuristic function in CPathFinder has been fixed. Now, the monsters correctly follow their targets without any problems. They are now able to effectively navigate around obstacles and move in a straight path. Additionally, the problem of zig-zag issue following in the South direction has been addressed. +- Added: Switch of heuristic function by activating a new flag on sphere.ini \ No newline at end of file diff --git a/src/game/CPathFinder.cpp b/src/game/CPathFinder.cpp index 89ff8bb2b..204f8aa86 100644 --- a/src/game/CPathFinder.cpp +++ b/src/game/CPathFinder.cpp @@ -8,11 +8,12 @@ int CPathFinder::Heuristic(const CPathFinderPoint* Pt1, const CPathFinderPoint* Pt2) noexcept // static { - // Hexagonal heuristic (thought for a hexagonal grid, but in our case, by using this, the movements are more natural and the rotation angles more wide) - //return 10*(abs(Pt1->m_x - Pt2->m_x) + abs(Pt1->m_y - Pt2->m_y)); + if (g_Cfg.m_iNpcAi & NPC_AI_HEURISTIC) + // Hexagonal heuristic (thought for a hexagonal grid, but in our case, by using this, the movements are more natural and the rotation angles more wide) + return 10 * (abs(Pt1->m_x - Pt2->m_x) + abs(Pt1->m_y - Pt2->m_y)); - // Diagonal heuristic, thought for a square grid which allows movement in 8 directions from a cell (our case) - return std::max(abs(Pt1->m_x - Pt2->m_x), abs(Pt1->m_y - Pt2->m_y)); + // Diagonal heuristic, thought for a square grid which allows movement in 8 directions from a cell (our case) + return std::max(abs(Pt1->m_x - Pt2->m_x), abs(Pt1->m_y - Pt2->m_y)); } void CPathFinder::GetAdjacentCells(const CPathFinderPoint* Point, std::deque& AdjacentCellsRefList ) diff --git a/src/game/CServerConfig.h b/src/game/CServerConfig.h index 4ffb136a1..1e658181d 100644 --- a/src/game/CServerConfig.h +++ b/src/game/CServerConfig.h @@ -468,6 +468,7 @@ extern class CServerConfig : public CResourceBase #define NPC_AI_MOVEOBSTACLES 0x00200 // If moveable items block my way, try to move them. #define NPC_AI_PERSISTENTPATH 0x00400 // NPC will try often to find a path with pathfinding. #define NPC_AI_THREAT 0x00800 // Enable the use of the threat variable when finding for target while fighting. +#define NPC_AI_HEURISTIC 0x01000 // Activate hexagonal heuristic function, if disabled, diagonal will be used. uint m_iNpcAi; // NPCAI Flags. // Experience system diff --git a/src/sphere.ini b/src/sphere.ini index c9cc0d5d3..ee12cc3bd 100644 --- a/src/sphere.ini +++ b/src/sphere.ini @@ -639,6 +639,7 @@ CanSeeSamePLevel=0 // NPC_AI_MOVEOBSTACLES 00200 Make NPCs with CAN=mt_usehands able to move items blocking its way // NPC_AI_PERSISTENTPATH 00400 Make NPCs try to follow its target even when it is unreachable instead give up // NPC_AI_THREAT 00800 Make NPCs attack targets that have higher threat level in combat +// NPC_AI_HEURISTIC 01000 Use hexagonal heuristic function for NPC Pathfinding instead of diagonal //NPCAI=0 /////////////////////////////////////////////////////////////// From d12758c436ee2e3c96fa31bdb5c8373312deb487 Mon Sep 17 00:00:00 2001 From: Luxion <76599640+LuxionUO@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:30:23 +0100 Subject: [PATCH 3/4] Added GuildNotoriety depending on Align Added OF_EnableGuildAlignNotoriety on Sphere.ini, if enabled guilds with different align (Chaos/Order) will see each other enemies or ally. --- Changelog.txt | 4 +++- src/game/CPathFinder.cpp | 5 ++--- src/game/CServerConfig.h | 4 ++-- src/game/chars/CCharNotoriety.cpp | 14 ++++++++++++++ src/sphere.ini | 1 + 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index d07097eb5..961804b0a 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3306,4 +3306,6 @@ Fixed: Multi type items weren't calling the @Destroy triggers when removed. (Iss 23-08-2023, Luxion - Fixed: The issue with the Heuristic function in CPathFinder has been fixed. Now, the monsters correctly follow their targets without any problems. They are now able to effectively navigate around obstacles and move in a straight path. Additionally, the problem of zig-zag issue following in the South direction has been addressed. -- Added: Switch of heuristic function by activating a new flag on sphere.ini \ No newline at end of file + +29-08-2023, Luxion +- Added: OF_EnableGuildAlignNotoriety in sphere.ini, if enabled, guilds with the same align will see each other enemies or ally. \ No newline at end of file diff --git a/src/game/CPathFinder.cpp b/src/game/CPathFinder.cpp index 204f8aa86..83f95183a 100644 --- a/src/game/CPathFinder.cpp +++ b/src/game/CPathFinder.cpp @@ -8,9 +8,8 @@ int CPathFinder::Heuristic(const CPathFinderPoint* Pt1, const CPathFinderPoint* Pt2) noexcept // static { - if (g_Cfg.m_iNpcAi & NPC_AI_HEURISTIC) - // Hexagonal heuristic (thought for a hexagonal grid, but in our case, by using this, the movements are more natural and the rotation angles more wide) - return 10 * (abs(Pt1->m_x - Pt2->m_x) + abs(Pt1->m_y - Pt2->m_y)); + // Hexagonal heuristic (thought for a hexagonal grid, but in our case, by using this, the movements are more natural and the rotation angles more wide) + //return 10 * (abs(Pt1->m_x - Pt2->m_x) + abs(Pt1->m_y - Pt2->m_y)); // Diagonal heuristic, thought for a square grid which allows movement in 8 directions from a cell (our case) return std::max(abs(Pt1->m_x - Pt2->m_x), abs(Pt1->m_y - Pt2->m_y)); diff --git a/src/game/CServerConfig.h b/src/game/CServerConfig.h index 1e658181d..c65f708d0 100644 --- a/src/game/CServerConfig.h +++ b/src/game/CServerConfig.h @@ -81,7 +81,8 @@ enum OF_TYPE OF_GuardOutsideGuardedArea = 0x0200000, // Allow guards to walk in unguarded areas, instead of being teleported back to their home point. OF_OWNoDropCarriedItem = 0x0400000, // When overweighted, don't drop items on ground when moving them (or using BOUNCE) and checking if you can carry them. OF_AllowContainerInsideContainer = 0x0800000, //Allow containers inside other containers even if they are heavier than the container being inserted into. - OF_VendorStockLimit = 0x01000000 // Limits how much of an item a vendor can buy using the value set in the TEMPLATE. Format: BUY=ID,AMOUNT + OF_VendorStockLimit = 0x01000000, // Limits how much of an item a vendor can buy using the value set in the TEMPLATE. Format: BUY=ID,AMOUNT + OF_EnableGuildAlignNotoriety = 0x02000000 // If enabled, guilds with the same alignment will see each other as enemy or ally. }; /** @@ -468,7 +469,6 @@ extern class CServerConfig : public CResourceBase #define NPC_AI_MOVEOBSTACLES 0x00200 // If moveable items block my way, try to move them. #define NPC_AI_PERSISTENTPATH 0x00400 // NPC will try often to find a path with pathfinding. #define NPC_AI_THREAT 0x00800 // Enable the use of the threat variable when finding for target while fighting. -#define NPC_AI_HEURISTIC 0x01000 // Activate hexagonal heuristic function, if disabled, diagonal will be used. uint m_iNpcAi; // NPCAI Flags. // Experience system diff --git a/src/game/chars/CCharNotoriety.cpp b/src/game/chars/CCharNotoriety.cpp index 8faee42a3..dc57a7f91 100644 --- a/src/game/chars/CCharNotoriety.cpp +++ b/src/game/chars/CCharNotoriety.cpp @@ -210,6 +210,20 @@ NOTO_TYPE CChar::Noto_CalcFlag(const CChar * pCharViewer, bool fAllowIncog, bool { if (pViewerGuild && pViewerGuild->IsPrivMember(pCharViewer)) { + if (IsSetOF(OF_EnableGuildAlignNotoriety)) + { + if (pViewerGuild->GetAlignType() != STONEALIGN_STANDARD) + { + if (pViewerGuild->GetAlignType() == pMyGuild->GetAlignType()) + { + return NOTO_GUILD_SAME; + } + + return NOTO_GUILD_WAR; + + } + } + if (pViewerGuild == pMyGuild) // Same guild? return NOTO_GUILD_SAME; // return green if (pMyGuild->IsAlliedWith(pViewerGuild)) diff --git a/src/sphere.ini b/src/sphere.ini index ee12cc3bd..8e422b5b2 100644 --- a/src/sphere.ini +++ b/src/sphere.ini @@ -802,6 +802,7 @@ Experimental=0 // OF_OWNoDropCarriedItem 00400000 // When overweighted, don't drop items on ground when moving them (or using BOUNCE) and checking if you can carry them. // OF_AllowContainerInsideContainer 00800000 // Allow containers inside other containers even if they are heavier than the container being inserted into. // OF_VendorStockLimit 01000000 // Limits how much of an item a vendor can buy using the value set in the TEMPLATE. Format: BUY=ID,AMOUNT +// OF_EnableGuildAlignNotoriety 02000000 // If enabled, guilds with the same alignment will see each other as enemy or ally. OptionFlags=08|080|0200 // Area flags From 6e4830c6792598432044f8882f3ee0e6a44c0406 Mon Sep 17 00:00:00 2001 From: Luxion <76599640+LuxionUO@users.noreply.github.com> Date: Tue, 29 Aug 2023 18:24:23 +0100 Subject: [PATCH 4/4] Heuristic setting removed from INI file --- src/sphere.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sphere.ini b/src/sphere.ini index 8e422b5b2..141fd45fa 100644 --- a/src/sphere.ini +++ b/src/sphere.ini @@ -639,7 +639,6 @@ CanSeeSamePLevel=0 // NPC_AI_MOVEOBSTACLES 00200 Make NPCs with CAN=mt_usehands able to move items blocking its way // NPC_AI_PERSISTENTPATH 00400 Make NPCs try to follow its target even when it is unreachable instead give up // NPC_AI_THREAT 00800 Make NPCs attack targets that have higher threat level in combat -// NPC_AI_HEURISTIC 01000 Use hexagonal heuristic function for NPC Pathfinding instead of diagonal //NPCAI=0 ///////////////////////////////////////////////////////////////