2026/04/25 Update

Tentatively fixed scrying for NWN:EE.
Added SCRY_AREA_BLOCKED & SCRY_FROM_AREA_BLOCKED area variables to control scrying.
Updated all scrying spells, powers & abilities  to use the above variables.
This commit is contained in:
Jaysyn904
2026-04-25 21:01:33 -04:00
parent 5d111437e0
commit f2fae74d01
16 changed files with 628 additions and 208 deletions

View File

@@ -114,10 +114,10 @@ void ApplyScryEffects(object oPC)
void main()
{
object oPC = OBJECT_SELF;
object oPC = OBJECT_SELF;
DeleteLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR");
SetLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_DIVINATION);
DeleteLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR");
SetLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_DIVINATION);
if (!X2PreSpellCastCode())
{
@@ -125,26 +125,33 @@ SetLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_DIVINATION);
return;
}
//Declare major variables
object oTarget;
int nCasterLvl = PRCGetCasterLevel(oPC);
int nSpell = PRCGetSpellId();
float fDur = 60.0 * nCasterLvl;
int nMetaMagic = PRCGetMetaMagicFeat();
//Make Metamagic check for extend
if ((nMetaMagic & METAMAGIC_EXTEND))
{
fDur = fDur * 2;
}
SetLocalInt(oPC, "ScryCasterLevel", nCasterLvl);
SetLocalInt(oPC, "ScrySpellId", nSpell);
SetLocalFloat(oPC, "ScryDuration", fDur);
StartDynamicConversation("prc_scry_conv", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
// Apply the immunity effects
ApplyScryEffects(oPC);
// Check if current area blocks scrying
if(GetLocalInt(GetArea(oPC), "SCRY_FROM_AREA_BLOCKED"))
{
FloatingTextStringOnCreature("This area prevents scrying.", oPC, FALSE);
return;
}
//Declare major variables
object oTarget;
int nCasterLvl = PRCGetCasterLevel(oPC);
int nSpell = PRCGetSpellId();
float fDur = 60.0 * nCasterLvl;
int nMetaMagic = PRCGetMetaMagicFeat();
//Make Metamagic check for extend
if ((nMetaMagic & METAMAGIC_EXTEND))
{
fDur = fDur * 2;
}
SetLocalInt(oPC, "ScryCasterLevel", nCasterLvl);
SetLocalInt(oPC, "ScrySpellId", nSpell);
SetLocalFloat(oPC, "ScryDuration", fDur);
StartDynamicConversation("prc_scry_conv", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
// Apply the immunity effects
ApplyScryEffects(oPC);
DeleteLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR");
// Getting rid of the integer used to hold the spells spell school

View File

@@ -26,8 +26,6 @@ const int STAGE_CONFIRMATION = 1;
//////////////////////////////////////////////////
/* Aid functions */
//////////////////////////////////////////////////
void StorePCForRecovery(object oPC, object oChoice, int nChoice)
{
SetLocalObject(oPC, "ScryTarget" + IntToString(nChoice), oChoice);
@@ -38,7 +36,188 @@ object RetrievePC(object oPC, int nChoice)
return GetLocalObject(oPC, "ScryTarget" + IntToString(nChoice));
}
void AddLegalTargets(object oPC)
void AddLegalTargets(object oPC)
{
// This reads all of the legal choices
int nSpellId = GetLocalInt(oPC, "ScrySpellId");
int nChoice = 1;
int nDebugCounter = 0; // Add debug counter for frequency limiting
if (nSpellId == SPELL_LOCATE_OBJECT)
{
// First, get all objects in the area you're in
object oObject = GetFirstObjectInArea(GetArea(oPC));
while (GetIsObjectValid(oObject) == TRUE)
{
if(DEBUG && (++nDebugCounter % 10 == 0))
DoDebug("prc_scry_conv: Processed " + IntToString(nDebugCounter) + " objects");
// Don't target PCs using this
if (GetObjectType(oObject) == OBJECT_TYPE_PLACEABLE || GetObjectType(oObject) == OBJECT_TYPE_ITEM)
{
// Check if object's area blocks scrying
if(!GetLocalInt(GetArea(oObject), "SCRY_AREA_BLOCKED"))
{
// If its a legal object, target it for locating
AddChoice(GetName(oObject), nChoice, oPC);
StorePCForRecovery(oPC, oObject, nChoice);
}
}
nChoice += 1;
oObject = GetNextObjectInArea(GetArea(oPC));
}
}
else
{
// First, get all creatures in the area you're in
object oCreature = GetFirstObjectInArea(GetArea(oPC));
while (GetIsObjectValid(oCreature) == TRUE)
{
if(DEBUG && (++nDebugCounter % 10 == 0))
DoDebug("prc_scry_conv: Processed " + IntToString(nDebugCounter) + " creatures");
// Don't target PCs using this
if (GetObjectType(oCreature) == OBJECT_TYPE_CREATURE)
{
// Check if creature's area blocks scrying
if(!GetLocalInt(GetArea(oCreature), "SCRY_AREA_BLOCKED"))
{
// This can target PCs in the area, but not in other areas
if ((nSpellId == SPELL_CLAIRAUDIENCE_AND_CLAIRVOYANCE ||
nSpellId == SPELL_LOCATE_CREATURE ||
nSpellId == MYST_TRAIL_OF_HAZE ||
nSpellId == POWER_CLAIRVOYANT_SENSE) &&
oPC != oCreature &&
!GetIsDM(oCreature))
{
AddChoice(GetName(oCreature), nChoice, oPC);
StorePCForRecovery(oPC, oCreature, nChoice);
}
// Normally, the second part takes care of all PCs
else if ((!GetIsPC(oCreature) && !GetIsDM(oCreature)))
{
AddChoice(GetName(oCreature), nChoice, oPC);
StorePCForRecovery(oPC, oCreature, nChoice);
}
}
}
nChoice += 1;
oCreature = GetNextObjectInArea(GetArea(oPC));
}
// These only target in their own areas
if (nSpellId != SPELL_CLAIRAUDIENCE_AND_CLAIRVOYANCE &&
nSpellId != SPELL_LOCATE_CREATURE &&
nSpellId != MYST_TRAIL_OF_HAZE &&
nSpellId != POWER_CLAIRVOYANT_SENSE)
{
// Now, loop through all of the PCs
object oPCTarget = GetFirstPC();
// Don't target yourself
while (GetIsObjectValid(oPCTarget))
{
if(oPCTarget != oPC && !GetIsDM(oPCTarget))
{
if(DEBUG && (++nDebugCounter % 10 == 0))
DoDebug("prc_scry_conv: Processed " + IntToString(nDebugCounter) + " PC targets");
// Check if PC's area blocks scrying
if(!GetLocalInt(GetArea(oPCTarget), "SCRY_AREA_BLOCKED"))
{
AddChoice(GetName(oPCTarget), nChoice, oPC);
StorePCForRecovery(oPC, oPCTarget, nChoice);
}
nChoice += 1;
}
oPCTarget = GetNextPC();
}
}
}
}
/* void AddLegalTargets(object oPC)
{
// This reads all of the legal choices
int nSpellId = GetLocalInt(oPC, "ScrySpellId");
int nChoice = 1;
int nDebugCounter = 0; // Add debug counter for frequency limiting
if (nSpellId == SPELL_LOCATE_OBJECT)
{
// First, get all objects in the area you're in
object oObject = GetFirstObjectInArea(GetArea(oPC));
while (GetIsObjectValid(oObject) == TRUE)
{
if(DEBUG && (++nDebugCounter % 10 == 0))
DoDebug("prc_scry_conv: Processed " + IntToString(nDebugCounter) + " objects");
// Don't target PCs using this
if (GetObjectType(oObject) == OBJECT_TYPE_PLACEABLE || GetObjectType(oObject) == OBJECT_TYPE_ITEM)
{
// If its a legal object, target it for locating
AddChoice(GetName(oObject), nChoice, oPC);
StorePCForRecovery(oPC, oObject, nChoice);
}
nChoice += 1;
oObject = GetNextObjectInArea(GetArea(oPC));
}
}
else
{
// First, get all creatures in the area you're in
object oCreature = GetFirstObjectInArea(GetArea(oPC));
while (GetIsObjectValid(oCreature) == TRUE)
{
if(DEBUG && (++nDebugCounter % 10 == 0))
DoDebug("prc_scry_conv: Processed " + IntToString(nDebugCounter) + " creatures");
// Don't target PCs using this
if (GetObjectType(oCreature) == OBJECT_TYPE_CREATURE)
{
// This can target PCs in the area, but not in other areas
if ((nSpellId == SPELL_CLAIRAUDIENCE_AND_CLAIRVOYANCE ||
nSpellId == SPELL_LOCATE_CREATURE ||
nSpellId == MYST_TRAIL_OF_HAZE ||
nSpellId == POWER_CLAIRVOYANT_SENSE) &&
oPC != oCreature &&
!GetIsDM(oCreature))
{
AddChoice(GetName(oCreature), nChoice, oPC);
StorePCForRecovery(oPC, oCreature, nChoice);
}
// Normally, the second part takes care of all PCs
else if ((!GetIsPC(oCreature) && !GetIsDM(oCreature)))
{
AddChoice(GetName(oCreature), nChoice, oPC);
StorePCForRecovery(oPC, oCreature, nChoice);
}
}
nChoice += 1;
oCreature = GetNextObjectInArea(GetArea(oPC));
}
// These only target in their own areas
if (nSpellId != SPELL_CLAIRAUDIENCE_AND_CLAIRVOYANCE &&
nSpellId != SPELL_LOCATE_CREATURE &&
nSpellId != MYST_TRAIL_OF_HAZE &&
nSpellId != POWER_CLAIRVOYANT_SENSE)
{
// Now, loop through all of the PCs
object oPCTarget = GetFirstPC();
// Don't target yourself
while (GetIsObjectValid(oPCTarget))
{
if(oPCTarget != oPC && !GetIsDM(oPCTarget))
{
if(DEBUG && (++nDebugCounter % 10 == 0))
DoDebug("prc_scry_conv: Processed " + IntToString(nDebugCounter) + " PC targets");
AddChoice(GetName(oPCTarget), nChoice, oPC);
StorePCForRecovery(oPC, oPCTarget, nChoice);
nChoice += 1;
}
oPCTarget = GetNextPC();
}
}
}
}
*/
/* void AddLegalTargets(object oPC)
{
// This reads all of the legal choices
int nSpellId = GetLocalInt(oPC, "ScrySpellId");
@@ -116,7 +295,7 @@ void AddLegalTargets(object oPC)
}
}
}
*/
//////////////////////////////////////////////////
/* Main function */
//////////////////////////////////////////////////
@@ -220,6 +399,7 @@ void main()
if (GetIsSkillSuccessful(oPC, SKILL_TRUESPEAK, nDC))
{ // The function will take it from here
ScryMain(oPC, oChoice);
}
else // Clean up effects
{
@@ -230,6 +410,7 @@ void main()
{
// The function will take it from here
ScryMain(oPC, oChoice);
}
// And we're all done

View File

@@ -129,6 +129,13 @@ SetLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_DIVINATION);
return;
}
// Check if current area blocks scrying
if(GetLocalInt(GetArea(oPC), "SCRY_FROM_AREA_BLOCKED"))
{
FloatingTextStringOnCreature("This area prevents scrying.", oPC, FALSE);
return;
}
//Declare major variables
object oTarget;
int nCasterLvl = PRCGetCasterLevel(oPC);

View File

@@ -28,6 +28,13 @@ SetLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_DIVINATION);
return;
}
// Check if current area blocks scrying
if(GetLocalInt(GetArea(oPC), "SCRY_FROM_AREA_BLOCKED"))
{
FloatingTextStringOnCreature("This area prevents scrying.", oPC, FALSE);
return;
}
//Declare major variables
object oTarget;
int nCasterLvl = PRCGetCasterLevel(oPC);

View File

@@ -114,41 +114,48 @@ void ApplyScryEffects(object oPC)
void main()
{
object oPC = OBJECT_SELF;
object oPC = OBJECT_SELF;
DeleteLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR");
SetLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_DIVINATION);
DeleteLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR");
SetLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_DIVINATION);
if (!X2PreSpellCastCode())
{
// If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
return;
}
// Check if current area blocks scrying
if(GetLocalInt(GetArea(oPC), "SCRY_FROM_AREA_BLOCKED"))
{
FloatingTextStringOnCreature("This area prevents scrying.", oPC, FALSE);
return;
}
//Declare major variables
object oTarget;
int nCasterLvl = PRCGetCasterLevel(oPC);
int nSpell = PRCGetSpellId();
int nDC = PRCGetSaveDC(oTarget, oPC);
float fDur = HoursToSeconds(nCasterLvl);
int nMetaMagic = PRCGetMetaMagicFeat();
//Make Metamagic check for extend
if ((nMetaMagic & METAMAGIC_EXTEND))
{
fDur = fDur * 2;
}
SetLocalInt(oPC, "ScryCasterLevel", nCasterLvl);
SetLocalInt(oPC, "ScrySpellId", nSpell);
SetLocalInt(oPC, "ScrySpellDC", nDC);
SetLocalFloat(oPC, "ScryDuration", fDur);
//AssignCommand(oPC, ClearAllActions(TRUE));
StartDynamicConversation("prc_scry_conv", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
// Apply the immunity effects
ApplyScryEffects(oPC);
//Declare major variables
object oTarget;
int nCasterLvl = PRCGetCasterLevel(oPC);
int nSpell = PRCGetSpellId();
int nDC = PRCGetSaveDC(oTarget, oPC);
float fDur = HoursToSeconds(nCasterLvl);
int nMetaMagic = PRCGetMetaMagicFeat();
//Make Metamagic check for extend
if ((nMetaMagic & METAMAGIC_EXTEND))
{
fDur = fDur * 2;
}
SetLocalInt(oPC, "ScryCasterLevel", nCasterLvl);
SetLocalInt(oPC, "ScrySpellId", nSpell);
SetLocalInt(oPC, "ScrySpellDC", nDC);
SetLocalFloat(oPC, "ScryDuration", fDur);
//AssignCommand(oPC, ClearAllActions(TRUE));
StartDynamicConversation("prc_scry_conv", oPC, DYNCONV_EXIT_NOT_ALLOWED, FALSE, TRUE, oPC);
// Apply the immunity effects
ApplyScryEffects(oPC);
DeleteLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR");
// Getting rid of the integer used to hold the spells spell school
DeleteLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR");
// Getting rid of the integer used to hold the spells spell school
}

View File

@@ -28,6 +28,13 @@ SetLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_DIVINATION);
return;
}
// Check if current area blocks scrying
if(GetLocalInt(GetArea(oPC), "SCRY_FROM_AREA_BLOCKED"))
{
FloatingTextStringOnCreature("This area prevents scrying.", oPC, FALSE);
return;
}
//Declare major variables
object oTarget;
int nCasterLvl = PRCGetCasterLevel(oPC);

View File

@@ -28,6 +28,13 @@ SetLocalInt(oPC, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_DIVINATION);
return;
}
// Check if current area blocks scrying
if(GetLocalInt(GetArea(oPC), "SCRY_FROM_AREA_BLOCKED"))
{
FloatingTextStringOnCreature("This area prevents scrying.", oPC, FALSE);
return;
}
//Declare major variables
object oTarget;
int nCasterLvl = PRCGetCasterLevel(oPC);

View File

@@ -130,7 +130,14 @@ void main()
if(nMetaMagic & METAMAGIC_EXTEND)
fDur *= 2;
SetLocalInt(oPC, "ScryCasterLevel", nCasterLvl);
// Check if current area blocks scrying
if(GetLocalInt(GetArea(oPC), "SCRY_FROM_AREA_BLOCKED"))
{
FloatingTextStringOnCreature("This area prevents scrying.", oPC, FALSE);
return;
}
SetLocalInt(oPC, "ScryCasterLevel", nCasterLvl);
SetLocalInt(oPC, "ScrySpellId", nSpell);
SetLocalInt(oPC, "ScrySpellDC", nDC);
SetLocalFloat(oPC, "ScryDuration", fDur);