From ca93f6ae42f8913a2da9da672e34045fbebd8f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caner=20K=C4=B1l=C4=B1=C3=A7o=C4=9Flu?= Date: Tue, 25 Nov 2025 15:41:43 +0300 Subject: [PATCH 1/4] NPC's spell cast range --- Changelog.txt | 3 +++ src/game/chars/CCharNPCAct_Magic.cpp | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index eb6bead1f..bca6993c2 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4077,3 +4077,6 @@ When setting a property like MORE to the a spell or skill defname, trying to rea - Changed: Object timers are now saved in worldsave files as TIMERMS, to avoid ambiguity and reliance on git build number to determine if TIMER expressed a number in seconds or milliseconds. - Changed: Added 5 seconds timeout to DNS hostname resolution at startup (avoid getting stuck when connectivity is enabled but not working). - Changed: CANMASK formatted in worldsave files as hexadecimal number, instead of decimal. + +25-11-2025, canerksk +- Changed: Fixed distance adjustments for NPCs in Magery fighting have been adjusted. The maximum distance can be set based on the OVERRIDE.MAXDIST or RANGE value for the entity. \ No newline at end of file diff --git a/src/game/chars/CCharNPCAct_Magic.cpp b/src/game/chars/CCharNPCAct_Magic.cpp index f1d3513e1..cb0f8af49 100644 --- a/src/game/chars/CCharNPCAct_Magic.cpp +++ b/src/game/chars/CCharNPCAct_Magic.cpp @@ -169,8 +169,16 @@ bool CChar::NPC_FightMagery(CChar * pChar) if ((iSpellCount < 1) && !pWand) return false; + int iMaxDist = ((UO_MAP_VIEW_SIGHT * 3) / 4); // (14 * 3) / 4 = 10 + if (pChar->_uiRange) + iMaxDist = pChar->_uiRange; // char range + + CVarDefCont *pValueMaxDist = GetKey("OVERRIDE.MAXDIST", true); + if (pValueMaxDist) + iMaxDist = (int)pValueMaxDist->GetValNum(); + int iDist = GetTopDist3D(pChar); - if (iDist > ((UO_MAP_VIEW_SIGHT * 3) / 4)) // way too far away . close in. + if (iDist > iMaxDist) // way too far away . close in. return false; if ((iDist <= 1) && (Skill_GetBase(SKILL_TACTICS) > 200) && (!g_Rand.GetVal(2))) From 3edf64cf2aa2b555260aad7daf8b21846cea8a2e Mon Sep 17 00:00:00 2001 From: cbnolok Date: Fri, 5 Dec 2025 14:27:36 +0100 Subject: [PATCH 2/4] Change max distance key from OVERRIDE.MAXDIST to OVERRIDE.SPELL_MAXDIST --- src/game/chars/CCharNPCAct_Magic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/chars/CCharNPCAct_Magic.cpp b/src/game/chars/CCharNPCAct_Magic.cpp index cb0f8af49..7399b4920 100644 --- a/src/game/chars/CCharNPCAct_Magic.cpp +++ b/src/game/chars/CCharNPCAct_Magic.cpp @@ -173,7 +173,7 @@ bool CChar::NPC_FightMagery(CChar * pChar) if (pChar->_uiRange) iMaxDist = pChar->_uiRange; // char range - CVarDefCont *pValueMaxDist = GetKey("OVERRIDE.MAXDIST", true); + CVarDefCont *pValueMaxDist = GetKey("OVERRIDE.SPELL_MAXDIST", true); if (pValueMaxDist) iMaxDist = (int)pValueMaxDist->GetValNum(); From ac8b1f3c4a7a7d4cb917aea01a892c9760928763 Mon Sep 17 00:00:00 2001 From: cbnolok Date: Fri, 5 Dec 2025 14:29:33 +0100 Subject: [PATCH 3/4] Revise NPC casting distance and add new tag for max distance Updated NPC casting mechanics and distance adjustments. --- Changelog.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index bca6993c2..d802cd487 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4078,5 +4078,6 @@ When setting a property like MORE to the a spell or skill defname, trying to rea - Changed: Added 5 seconds timeout to DNS hostname resolution at startup (avoid getting stuck when connectivity is enabled but not working). - Changed: CANMASK formatted in worldsave files as hexadecimal number, instead of decimal. -25-11-2025, canerksk -- Changed: Fixed distance adjustments for NPCs in Magery fighting have been adjusted. The maximum distance can be set based on the OVERRIDE.MAXDIST or RANGE value for the entity. \ No newline at end of file +05-12-2025, canerksk +- Changed: NPCs cast distance now depends on the caster's RANGE. +- Added: TAG.OVERRIDE.SPELL_MAXDIST to set a custom maximum distance from the target for spellcasting. From e2aacea40a79ac1661179cfff8adbed7d43c0f6a Mon Sep 17 00:00:00 2001 From: cbnolok Date: Fri, 5 Dec 2025 14:32:36 +0100 Subject: [PATCH 4/4] Refine NPCs cast distance based on RANGE setting Updated NPCs cast distance logic to consider default value. --- Changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 38d5a21d6..95c8a7932 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4096,5 +4096,5 @@ When setting a property like MORE to the a spell or skill defname, trying to rea - Fixed: REGION ISEVENT didn't (always?) find REGIONTYPES. 05-12-2025, canerksk -- Changed: NPCs cast distance now depends on the caster's RANGE. +- Changed: NPCs cast distance now depends on the caster's RANGE (if set, otherwise fall back to the default value). - Added: TAG.OVERRIDE.SPELL_MAXDIST to set a custom maximum distance from the target for spellcasting.