diff --git a/Changelog.txt b/Changelog.txt index fa03b7df8..95c8a7932 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4094,3 +4094,7 @@ When setting a property like MORE to the a spell or skill defname, trying to rea 4-12-2025, Nolok - Fixed: Malformed spell flags being returned via scripts. - Fixed: REGION ISEVENT didn't (always?) find REGIONTYPES. + +05-12-2025, canerksk +- 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. diff --git a/src/game/chars/CCharNPCAct_Magic.cpp b/src/game/chars/CCharNPCAct_Magic.cpp index f1d3513e1..7399b4920 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.SPELL_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)))