I made a script I thought would work, but it doesn’t seem to work. I want to check the entire party if someone has the spell Dispel Magic:
#include "ginc_var_ops"
#include "ginc_param_const"
int ItemsValid()
{
int bHasDispel = FALSE;
object oPC = GetFirstPC();
string sTag;
object oFM = GetFirstFactionMember(oPC,FALSE);
while(GetIsObjectValid(oFM))
{
object oItem = GetFirstItemInInventory();
while (GetIsObjectValid(oItem))
{
sTag = GetTag(oItem);
if (sTag == "nw_it_sparscr301")
{
bHasDispel = TRUE;
}
oItem = GetNextItemInInventory();
}
oFM = GetNextFactionMember(oPC, FALSE);
}
if(bHasDispel)
{
return TRUE;
}
return FALSE;
}
int HasTheSpell()
{
object oPC = GetFirstPC();
int bHasSpell = FALSE;
object oFM = GetFirstFactionMember(oPC,FALSE);
while(GetIsObjectValid(oFM))
{
if(GetHasSpell(SPELL_DISPEL_MAGIC,oFM))
{
bHasSpell = TRUE;
DecrementRemainingSpellUses(oFM, SPELL_DISPEL_MAGIC);
}
oFM = GetNextFactionMember(oPC, FALSE);
}
if(bHasSpell)
{
return TRUE;
}
return FALSE;
}
int StartingConditional()
{
if(HasTheSpell() || ItemsValid())
{
return TRUE;
}
return FALSE;
}
EDIT: So I modified the script with GetFirstPC(FALSE) and now it works if one of the characters have the spell as a spell slot, but if I pick up a scroll with Dispel Magic the script won’t recognize that. At first I thought it had to do with the tag being wrong but I corrected it and it still won’t recognize if you have the scroll in your inventory:
int ItemsValid()
{
int bHasDispel = FALSE;
object oPC = GetFirstPC(FALSE);
string sTag;
object oFM = GetFirstFactionMember(oPC,FALSE);
while(GetIsObjectValid(oFM))
{
object oItem = GetFirstItemInInventory();
while (GetIsObjectValid(oItem))
{
sTag = GetTag(oItem);
if (sTag == "NW_IT_SPARSCR301")
{
bHasDispel = TRUE;
}
oItem = GetNextItemInInventory();
}
oFM = GetNextFactionMember(oPC, FALSE);
}
if(bHasDispel)
{
return TRUE;
}
return FALSE;
}
int HasTheSpell()
{
object oPC = GetFirstPC(FALSE);
int bHasSpell = FALSE;
object oFM = GetFirstFactionMember(oPC,FALSE);
while(GetIsObjectValid(oFM))
{
if(GetHasSpell(SPELL_DISPEL_MAGIC,oFM))
{
bHasSpell = TRUE;
DecrementRemainingSpellUses(oFM, SPELL_DISPEL_MAGIC);
}
oFM = GetNextFactionMember(oPC, FALSE);
}
if(bHasSpell)
{
return TRUE;
}
return FALSE;
}
int StartingConditional()
{
if(HasTheSpell()) return TRUE;
else if(ItemsValid()) return TRUE;
return FALSE;
}